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()
File
- ./
ga4php.php, line 352
Class
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;
//echo "$bc was, $var is, $bin are\n";
}
$out2 = "";
$ar2 = str_split($out, 5);
foreach ($ar2 as $var2) {
$bc = base_convert($var2, 2, 10);
$out2 .= $alphabet[$bc];
}
return $out2;
}