getDomain(); if (!$domain) { throw new CryptographyException("Domain configuration is missing."); } return sprintf("otpauth://totp/%s:%s?secret=%s&issuer=%s", rawurlencode($domain), rawurlencode($account), rawurlencode($secretKey), rawurlencode($issuer)); } /** * Computes a hash-based message authentication code (HMAC) using the specified algorithm. * * @param string $algorithm The hashing algorithm to be used (e.g., 'sha1', 'sha256', 'sha384', 'sha512'). * @param string $data The data to be hashed. * @param string $key The secret key used for the HMAC generation. * * @return string The generated HMAC as a raw binary string. * * @*/ private static function hashHmac(string $algorithm, string $data, string $key): string { return match($algorithm) { 'sha1', 'sha256', 'sha384', 'sha512' => hash_hmac($algorithm, $data, $key, true), default => throw new CryptographyException('Algorithm not supported') }; } }