哔哩哔哩视频av和bv互转 PHP源码

子枫 [Rainy]
发布于 2022-06-13
473 浏览
class Bilibili{
protected $table = "fZodR9XQDSUm21yCkr6zBqiveYah8bt4xsWpHnJE7jL5VG3guMTKNPAwcF";
protected $tr = [];
protected $s = [11, 10, 3, 8, 4, 6];
protected $xor = 177451812;
protected $add = 8728348608;
public function __construct($id=null){
for ($i = 0; $i < 58; $i++) {
$this->tr[$this->table[$i]] = $i;
}
}
public function dec($id){
$r = 0;
for ($i = 0; $i < 6; $i++) {
$r += $this->tr[$id[$this->s[$i]]] 58 * $i;
}
return ($r - $this->add) ^ $this->xor;
}
public function enc($id){
$id = ($id ^ $this->xor) + $this->add;
$r = str_split('BV1 4 1 7 ');
for ($i = 0; $i < 6; $i++) {
$r[$this->s[$i]] = $this->table[floor($id / 58 $i) % 58];
}
return implode("",$r);
}
}$bl = new Bilibili();
//bv转av
echo $bl->dec('BV14S4y1m7bs'); //725281139
echo "<br>";
//av转bv
echo $bl->enc('725281139'); //BV14S4y1m7bs
评论 (56)
评论输入框评论列表
没有任何评论