From a82f517563d4abaf10324640317a5f671e4f6b61 Mon Sep 17 00:00:00 2001 From: Adam H Date: Mon, 11 Aug 2025 22:53:46 -0400 Subject: [PATCH] Fixed issues Deprecated: rawurlencode(): with $issuer. $out and $secret not being set before the return. --- src/TOTP.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/TOTP.php b/src/TOTP.php index 5b9f5da..05981c7 100644 --- a/src/TOTP.php +++ b/src/TOTP.php @@ -34,6 +34,7 @@ public function setAlgorithm($algorithm = 'sha1') public static function base32Decode($in) { + $out = ''; if (empty($in)) { return ''; } @@ -108,6 +109,7 @@ public function get($digits = 6, $period = 30, $offset = null, $now = null) public static function genSecret($length = 32) { + $secret = ''; if ($length < 16 || 0 != $length % 8) { throw new \Exception('length must >= 16 || %8==0'); } @@ -131,8 +133,11 @@ public function uri($account, $digits = null, $period = null, $issuer = null) if (false !== mb_strpos($account.$issuer, ':')) { throw new \Exception('cannot have colon in account / issuer'); } + $account = rawurlencode($account); - $issuer = rawurlencode($issuer); + if($issuer){ + $issuer = rawurlencode($issuer); + } $label = empty($issuer) ? $account : "{$issuer}:{$account}"; return 'otpauth://totp/'.$label."?secret={$secret}".