Skip to content

Commit 9142038

Browse files
authored
Add files via upload
1 parent f29b7bc commit 9142038

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Crypto/Base58.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ static public function dec2base(string | int $dec,int $base,string $digits = nul
1717
$value = strval(null);
1818
if(is_null($digits)) $digits = self::digits($base);
1919
while($dec > $base - 1):
20-
$rest = bcmod($dec,$base);
21-
$dec = bcdiv($dec,$base);
20+
$rest = bcmod(strval($dec),strval($base));
21+
$dec = bcdiv(strval($dec),strval($base));
2222
$value = $digits[intval($rest)].$value;
2323
endwhile;
2424
$value = $digits[intval($dec)].$value;
@@ -53,8 +53,8 @@ static public function base2dec(string $value,int $base,$digits = false) : strin
5353
$dec = strval(0);
5454
for($loop = 0;$loop < $size;$loop++):
5555
$element = strpos($digits,$value[$loop]);
56-
$power = bcpow($base,$size - $loop - 1);
57-
$dec = bcadd($dec,bcmul($element,$power));
56+
$power = bcpow(strval($base),strval($size - $loop - 1));
57+
$dec = bcadd($dec,bcmul(strval($element),$power));
5858
endfor;
5959
return ($dec <= PHP_INT_MAX and $dec >= PHP_INT_MIN) ? intval($dec) : strval($dec);
6060
else:

0 commit comments

Comments
 (0)