From 85d22fb3500aca6a9c2a6f1c3b7f10cf748ab4b4 Mon Sep 17 00:00:00 2001 From: her_finn Date: Fri, 2 Oct 2020 19:12:16 +0200 Subject: [PATCH] I added the function getOTPUrl to get the otp:// url from the secret --- PHPGangsta/GoogleAuthenticator.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/PHPGangsta/GoogleAuthenticator.php b/PHPGangsta/GoogleAuthenticator.php index bf7d116..db491f7 100644 --- a/PHPGangsta/GoogleAuthenticator.php +++ b/PHPGangsta/GoogleAuthenticator.php @@ -112,6 +112,22 @@ public function getQRCodeGoogleUrl($name, $secret, $title = null, $params = arra return "https://api.qrserver.com/v1/create-qr-code/?data=$urlencoded&size=${width}x${height}&ecc=$level"; } + /** + * Get OTP:// - Url + * @param string $name + * @param string $secret + * @param string $title + * + * @return string + */ + public function getOTPUrl($name,$secret,$title = null){ + $url = 'otpauth://totp/'.$name.'?secret='.$secret; + if (isset($title)) { + $url .= "&issuer=$title"; + } + return ($url); + } + /** * Check if the code is correct. This will accept codes starting from $discrepancy*30sec ago to $discrepancy*30sec from now. *