I've built a two PHP functions that convert the answers to my questionnaire into a non-human readable format Octal-blocks -> Base-32.
However the PHP editor tells me that I cannot run base_convert and str_split. Is there a way around this?
function str_baseconvert($str, $frombase=10, $tobase=36) {
$str = trim($str);
if (intval($frombase) != 10) {
$len = strlen($str);
$q = 0;
for ($i=0; $i<$len; $i++) {
$r = base_convert($str[$i], $frombase, 10);
$q = bcadd(bcmul($q, $frombase), $r);
}
}
else $q = $str;
if (intval($tobase) != 10) {
$s = '';
while (bccomp($q, '0', 0) > 0) {
$r = intval(bcmod($q, $tobase));
$s = base_convert($r, 10, $tobase) . $s;
$q = bcdiv($q, $tobase, 0);
}
}
else $s = $q;
return $s;
}
function base_5char($base8){
$base32= [];
$base8 = str_split($base8, 5);
foreach($base8 as $key => $value){
$base32[$key] = str_baseconvert($value, 8, 32);
if(strlen($base32[$key])==2){
$base32[$key] = "0".$base32[$key];
}
elseif(strlen($base32[$key])==1){
$base32[$key] = "00".$base32[$key];
}
}
return implode($base32);
}