Convert the digital base_convert between PHP arbitrary binary
http://php.net/manual/zh/function.base-convert.php
Actual testing due to the problem of loss of precision, will result in a replacement error.
Warning
Due to the use of internal "double" or "float" type, the operation of Base_convert () may result in loss of precision in large values. See the floating point numbers section of this manual for more details.
$s= ' Be55d904-1f35-4838-8f8f-b27edea9dfab ';$sha 1=SHA1($s);Echo $sha 1;Echo' <br/> ';$sha= Str_baseconvert ($sha 1, 16, 36);Echo $sha;Echo' <br/> ';$sha 1= Str_baseconvert ($sha, 36, 16);Echo $sha 1;Echo' <br/> ';functionStr_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; }
BC Math functions
http://php.net/manual/zh/ref.bc.php
16 binary string to 36 binary string