. */ namespace App\Helpers; use Illuminate\Support\Str; use App\Account; use App\DigestNonce; class Utils { public static function generateNonce(): string { return Str::random(32); } public static function generateValidNonce(Account $account): string { $nonce = new DigestNonce; $nonce->account_id = $account->id; $nonce->nonce = Utils::generateNonce(); $nonce->save(); return $nonce->nonce; } public static function bchash(string $username, string $domain, string $password, string $algorithm = 'MD5') { $algos = ['MD5' => 'md5', 'SHA-256' => 'sha256']; return hash($algos[$algorithm], $username.':'.$domain.':'.$password); } public static function generatePin() { return mt_rand(1000, 9999); } }