PHPverse 2025

Voting

: min(zero, eight)?
(Example: nine)

The Note You're Voting On

Anonymous
7 years ago
some other mini implementation of base32 without error catching. just bring things from 5 to 8 and 8 to 5 bit. greetings. mho

<?
function base32_decode($d)
{
list($t, $b, $r) = array("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", "", "");

foreach(str_split($d) as $c)
$b = $b . sprintf("%05b", strpos($t, $c));

foreach(str_split($b, 8) as $c)
$r = $r . chr(bindec($c));

return($r);
}

function base32_encode($d)
{
list($t, $b, $r) = array("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", "", "");

foreach(str_split($d) as $c)
$b = $b . sprintf("%08b", ord($c));

foreach(str_split($b, 5) as $c)
$r = $r . $t[bindec($c)];

return($r);
}
?>

<< Back to user notes page

To Top