function GoogleAuthenticator::createURL in Google Authenticator login 6
Same name and namespace in other branches
- 7 ga4php.php \GoogleAuthenticator::createURL()
1 call to GoogleAuthenticator::createURL()
1 method overrides GoogleAuthenticator::createURL()
File
- ./
ga4php.php, line 272
Class
Code
function createURL($user) {
// oddity in the google authenticator... hotp needs to be lowercase.
$data = $this
->internalGetData($user);
$toktype = $data["tokentype"];
$key = $this
->helperhex2b32($data["tokenkey"]);
// token counter should be one more then current token value, otherwise
// it gets confused
$counter = $data["tokencounter"] + 1;
$toktype = strtolower($toktype);
if ($toktype == "hotp") {
$url = "otpauth://{$toktype}/{$user}?secret={$key}&counter={$counter}";
}
else {
$url = "otpauth://{$toktype}/{$user}?secret={$key}";
}
//echo "url: $url\n";
return $url;
}