Beispiel #1
0
function bcdechex($num)
{
    $res = "";
    while ($num != '0') {
        $byte = bcand($num, 255);
        $hex = dechex($byte);
        if (strlen($hex) == 1) {
            $hex = '0' . $hex;
        }
        $res = $hex . $res;
        $num = bcrightshift($num, 8);
    }
    if ($res == '') {
        $res = 0;
    }
    return $res;
}
Beispiel #2
0
 function hash2location($hash)
 {
     $value = bchexdec($hash);
     $bits128 = $this->bits128;
     $location = bcxor(bcrightshift($value, 128), bcand($value, $bits128));
     return $this->leftPadHex(bcdechex($location), 32);
 }