Beispiel #1
0
function CodeFunc($Id, $artist, $title)
{
    $Id = (int) $Id;
    $utf8Str = SetToHexString(iconv('GBK', 'UTF-8', $artist . $title));
    $length = strlen($utf8Str) / 2;
    for ($i = 0; $i <= $length - 1; $i++) {
        eval('$song[' . $i . '] = 0x' . substr($utf8Str, $i * 2, 2) . ';');
    }
    $tmp2 = 0;
    $tmp3 = 0;
    $tmp1 = ($Id & 0xff00) >> 8;
    if (($Id & 0xff0000) == 0) {
        $tmp3 = 0xff & ~$tmp1;
    } else {
        $tmp3 = 0xff & ($Id & 0xff0000) >> 16;
    }
    $tmp3 = $tmp3 | (0xff & $Id) << 8;
    $tmp3 = $tmp3 << 8;
    $tmp3 = $tmp3 | 0xff & $tmp1;
    $tmp3 = $tmp3 << 8;
    //tmp3 0x18015F00
    if (($Id & 4278190080.0) == 0) {
        $tmp3 = $tmp3 | 0xff & ~$Id;
    } else {
        $tmp3 = $tmp3 | 0xff & $Id >> 24;
    }
    $i = $length - 1;
    while ($i >= 0) {
        $char = $song[$i];
        if ($char >= 0x80) {
            $char = $char - 0x100;
        }
        $tmp1 = $char + $tmp2 & 4294967295.0;
        $tmp2 = $tmp2 << $i % 2 + 4 & 4294967295.0;
        $tmp2 = $tmp1 + $tmp2 & 4294967295.0;
        $i -= 1;
    }
    $i = 0;
    $tmp1 = 0;
    while ($i <= $length - 1) {
        $char = $song[$i];
        if ($char >= 128) {
            $char = $char - 256;
        }
        $tmp7 = $char + $tmp1 & 4294967295.0;
        $tmp1 = $tmp1 << $i % 2 + 3 & 4294967295.0;
        $tmp1 = $tmp1 + $tmp7 & 4294967295.0;
        $i += 1;
    }
    $t = conv($tmp2 ^ $tmp3);
    $t = conv($t + ($tmp1 | $Id));
    $t = conv(bcmul($t, $tmp1 | $tmp3));
    $t = conv(bcmul($t, $tmp2 ^ $Id));
    if (bccomp($t, 2147483648.0) > 0) {
        $t = bcadd($t, -4294967296.0);
    }
    return $t;
}
Beispiel #2
0
function CodeFunc($Id, $artist, $title)
{
    $Id = (int) $Id;
    $utf8Str = SetToHexString($artist . $title);
    $length = strlen($utf8Str) / 2;
    for ($i = 0; $i <= $length - 1; $i++) {
        eval('$song[' . $i . '] = 0x' . substr($utf8Str, $i * 2, 2) . ';');
    }
    $tmp2 = 0;
    $tmp3 = 0;
    $tmp1 = ($Id & 0xff00) >> 8;
    //右移8位后为0x0000015F
    if (($Id & 0xff0000) == 0) {
        $tmp3 = 0xff & ~$tmp1;
        //CL 0x000000E7
    } else {
        $tmp3 = 0xff & ($Id & 0xff0000) >> 16;
        //右移16位后为0x00000001
    }
    $tmp3 = $tmp3 | (0xff & $Id) << 8;
    //tmp3 0x00001801
    $tmp3 = $tmp3 << 8;
    //tmp3 0x00180100
    $tmp3 = $tmp3 | 0xff & $tmp1;
    //tmp3 0x0018015F
    $tmp3 = $tmp3 << 8;
    //tmp3 0x18015F00
    if (($Id & 0xff000000) == 0) {
        $tmp3 = $tmp3 | 0xff & ~$Id;
        //tmp3 0x18015FE7
    } else {
        $tmp3 = $tmp3 | 0xff & $Id >> 24;
        //右移24位后为0x00000000
    }
    $i = $length - 1;
    while ($i >= 0) {
        $char = $song[$i];
        if ($char >= 0x80) {
            $char = $char - 0x100;
        }
        $tmp1 = $char + $tmp2 & 0xffffffff;
        $tmp2 = $tmp2 << $i % 2 + 4 & 0xffffffff;
        $tmp2 = $tmp1 + $tmp2 & 0xffffffff;
        $i -= 1;
    }
    $i = 0;
    $tmp1 = 0;
    while ($i <= $length - 1) {
        $char = $song[$i];
        if ($char >= 128) {
            $char = $char - 256;
        }
        $tmp7 = $char + $tmp1 & 0xffffffff;
        $tmp1 = $tmp1 << $i % 2 + 3 & 0xffffffff;
        $tmp1 = $tmp1 + $tmp7 & 0xffffffff;
        $i += 1;
    }
    $t = conv($tmp2 ^ $tmp3);
    $t = conv($t + ($tmp1 | $Id));
    $t = conv(bcmul($t, $tmp1 | $tmp3));
    $t = conv(bcmul($t, $tmp2 ^ $Id));
    if (bccomp($t, 2147483648) > 0) {
        $t = bcadd($t, -4294967296);
    }
    return $t;
}
Beispiel #3
0
function tt_code($str)
{
    $s = strtolower($str);
    $s = str_replace(" ", "", $s);
    $s = str_replace("'", "", $s);
    return SetToHexString(iconv('GBK', 'UTF-16LE', $s));
}