public function GoogleAuthenticator::helperhex2b32 in Google Authenticator login 7
Same name and namespace in other branches
- 6 ga4php.php \GoogleAuthenticator::helperhex2b32()
Convert hax to b32.
2 calls to GoogleAuthenticator::helperhex2b32()
- GALoginGA::createURL in ./
ga_login.class.php - Create authentication URL.
- GoogleAuthenticator::createURL in ./
ga4php.php - Create a url compatibile with google authenticator.
File
- ./
ga4php.php, line 362 - Abstract GoogleAuthenticator class.
Class
- GoogleAuthenticator
- @file Abstract GoogleAuthenticator class.
Code
public function helperhex2b32($hex) {
$alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
$ar = str_split($hex, 5);
$out = "";
foreach ($ar as $var) {
$bc = base_convert($var, 16, 2);
$bin = str_pad($bc, 20, "0", STR_PAD_LEFT);
$out .= $bin;
}
$out2 = "";
$ar2 = str_split($out, 5);
foreach ($ar2 as $var2) {
$bc = base_convert($var2, 2, 10);
$out2 .= $alphabet[$bc];
}
return $out2;
}