首页 学习笔记

WD丢弃算法php版本(纯php源码)


需要的拿去玩玩吧

<?php

function checksum(int $adler, string $data) :int
{
    $s1 = $adler & 65535;
    $s2 = ($adler >> 16) & 65535;
    $arr = str_split(bin2hex($data), 2);
    foreach($arr as $i) {
        $s1 = ($s1 + hexdec($i)) % 65521;
        $s2 = ($s2 + $s1) % 65521;
    }
    return ($s2 << 16) | $s1;
}

function intval32($num) {
    $num = $num & 0xffffffff;
    $p = $num >> 31;
    if($p == 1) {
        $num = $num - 1;
        $num = ~$num;
        $num = $num & 0xffffffff;
        return $num * -1;
    } else {
        return $num;
    }
}

$szTime = '20210812234852';
$nSeed = strtotime($szTime);
$szData = '0000000000000001';
$nSeed = checksum($nSeed, $szData);
$szData = '46264000124494474703';
$nSeed = checksum($nSeed, $szData);
$szData = '0';
$nSeed = checksum($nSeed, $szData);
$szData = '道具套餐卡:([255:36,233::46264000124494474703:,232:179,"type":8,"imp_item":0,47:1,273:1,])';
$szData = iconv('utf-8', 'gb2312//IGNORE', $szData);
$nSeed = checksum($nSeed, $szData);
$nSeed = $nSeed ^ hexdec('AB7932CF');
$nSeed = intval32($nSeed);

echo $nSeed;
echo "\n";

?>



文章评论