Browse Source

Base32::decode() cannot return boolean values.

tags/v0.1.0
Piotr Likoski 1 year ago
parent
commit
d2335c86b2
Signed by: likoski <likoski@codingworkshop.eu.org> GPG Key ID: D9556DDD74910B18
1 changed files with 3 additions and 3 deletions
  1. +3
    -3
      tests/base32_test.aer

+ 3
- 3
tests/base32_test.aer View File

@@ -42,10 +42,10 @@ class Base32 {
if(!$input) return '';
int $paddingCharCount = substr_count($input, Base32::$map[32]);
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++) {
if($paddingCharCount == $allowedValues[$i] && substr($input, -($allowedValues[$i])) != str_repeat(Base32::$map[32], $allowedValues[$i]))
return false;
return '';
}
$input = str_replace('=','', $input);
char[] $aInput = str_split($input);
@@ -53,7 +53,7 @@ class Base32 {
for($i = 0; $i < sizeof($aInput); $i = $i + 8) {
string $x = '';
if(!in_array($input[$i], Base32::$map))
return false;
return '';
for(int $j = 0; $j < 8; $j++) {
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);


Loading…
Cancel
Save