function GoogleAuthenticator::helperhex2b32 in Google Authenticator login 6
Same name and namespace in other branches
- 7 ga4php.php \GoogleAuthenticator::helperhex2b32()
2 calls to GoogleAuthenticator::helperhex2b32()
- ga_loginGA::createURL in ./ga_login.class.php
- GoogleAuthenticator::createURL in ./ga4php.php
File
- ./ga4php.php, line 352
Class
- GoogleAuthenticator
Code
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;
}