Exemplo n.º 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;
}
Exemplo n.º 2
0
 function decryptMessageID($messageID)
 {
     // saving last information for debug log
     $oldmid = $messageID;
     $oldkey = $this->enc_key1 >> 16 & 0x7fff;
     // calculating the encryption key
     $messageID = hexdec($messageID);
     $this->enc_key1 = bcand($this->enc_key3 + bcand(bcmul($this->enc_key1, $this->enc_key2), 0xffffffff), 0xffffffff) + 0;
     //$this->echo_save("$this->nl ".dechex($this->enc_key1)." ".dechex($this->enc_key2)." ".dechex($this->enc_key3)."\n");
     $newkey = $this->enc_key1 >> 16 & 0x7fff;
     // xoring the message id
     $messageID = ($messageID ^ $newkey) & 0xffff;
     $messageID = strtoupper(str_pad(dechex($messageID), 4, "0", STR_PAD_LEFT));
     // sting format to allow array lookup
     //$this->echo_save("$this->nl Encrypted MID : ".dechex($oldkey).",".dechex($newkey)."  $oldmid,$messageID \n");
     return $messageID;
 }
Exemplo n.º 3
0
 function hash2location($hash)
 {
     $value = bchexdec($hash);
     $bits128 = $this->bits128;
     $location = bcxor(bcrightshift($value, 128), bcand($value, $bits128));
     return $this->leftPadHex(bcdechex($location), 32);
 }