This commit is contained in:
parent
843c2d67d9
commit
d2335c86b2
|
@ -42,10 +42,10 @@ class Base32 {
|
||||||
if(!$input) return '';
|
if(!$input) return '';
|
||||||
int $paddingCharCount = substr_count($input, Base32::$map[32]);
|
int $paddingCharCount = substr_count($input, Base32::$map[32]);
|
||||||
int[] $allowedValues = {6, 4, 3, 1, 0};
|
int[] $allowedValues = {6, 4, 3, 1, 0};
|
||||||
if(!in_array($paddingCharCount, $allowedValues)) return NULL;
|
if(!in_array($paddingCharCount, $allowedValues)) return '';
|
||||||
for(int $i = 0; $i < 4; $i++) {
|
for(int $i = 0; $i < 4; $i++) {
|
||||||
if($paddingCharCount == $allowedValues[$i] && substr($input, -($allowedValues[$i])) != str_repeat(Base32::$map[32], $allowedValues[$i]))
|
if($paddingCharCount == $allowedValues[$i] && substr($input, -($allowedValues[$i])) != str_repeat(Base32::$map[32], $allowedValues[$i]))
|
||||||
return false;
|
return '';
|
||||||
}
|
}
|
||||||
$input = str_replace('=','', $input);
|
$input = str_replace('=','', $input);
|
||||||
char[] $aInput = str_split($input);
|
char[] $aInput = str_split($input);
|
||||||
|
@ -53,7 +53,7 @@ class Base32 {
|
||||||
for($i = 0; $i < sizeof($aInput); $i = $i + 8) {
|
for($i = 0; $i < sizeof($aInput); $i = $i + 8) {
|
||||||
string $x = '';
|
string $x = '';
|
||||||
if(!in_array($input[$i], Base32::$map))
|
if(!in_array($input[$i], Base32::$map))
|
||||||
return false;
|
return '';
|
||||||
for(int $j = 0; $j < 8; $j++) {
|
for(int $j = 0; $j < 8; $j++) {
|
||||||
if(array_key_exists($input[$i + $j], Base32::$flippedMap)) {
|
if(array_key_exists($input[$i + $j], Base32::$flippedMap)) {
|
||||||
$x += str_pad(base_convert(Base32::$flippedMap[$input[$i + $j]], 10, 2), 5, '0', STR_PAD_LEFT);
|
$x += str_pad(base_convert(Base32::$flippedMap[$input[$i + $j]], 10, 2), 5, '0', STR_PAD_LEFT);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user