Skip to content

Instantly share code, notes, and snippets.

Created February 6, 2014 07:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/8839784 to your computer and use it in GitHub Desktop.
Save anonymous/8839784 to your computer and use it in GitHub Desktop.
<?php
$a = 'qWNjnA';
$b = '33';
$str = base64_decode($a); // 对a进行base64解码
$str[0] = chr(ord($str[0]) - 115); // 第一位ASCII码减去 115
$b = strval(intval($b)); // 对b只取有效数字部分
$j = 0;
$magic_number = array(104, 101, 114, 111, 112, 97, 115, 115, 52);
$str_length = strlen($str);
for($i = 1; $i < $str_length; $i++) // 从第二位开始循环处理
{
$b_chr = ord($b[$i-1]);
if($b_chr)
{
$str[$i] = chr(ord($str[$i]) - $b_chr); // 如果对应位b有相应的值,则减去其ascii码值
}
else
{
$str[$i] = chr(ord($str[$i]) - $magic_number[($j++) % 9]); // 否则从一个幻数表里循环取值并减去
}
}
echo $str; // 结果应为 6004
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment