时间:2021-07-01 10:21:17 帮助过:14人阅读
[User:root Time:11:14:10 Path:/home/liangdong/php]$ php md5.php 07-3a-8a-c0-f6-22-12-23-f1-59-26-d8-32-c3-c5-38 [User:root Time:11:14:13 Path:/home/liangdong/php]$ cat md5.php [User:root Time:11:14:15 Path:/home/liangdong/php]$
------解决方案--------------------
搜索 70-66-A4-0F-42-77-69-CC-43-34-7A-A9-6B-72-93-1A
可知这个是 123456 的 MD5,而不是 111111 的 MD5
有人说转成 unicode 编码再 MD5 就可以得到
但遗憾的是 无论是转成 ucs-2be、ucs-2le、ucs-4le、ucs-4be 在php 中都不能 MD5 成
------解决方案--------------------
能凑活用:
$str = md5("111111");
echo $str . "
";
#96e79218965eb72c92a549dd5a330112
function encode($str) {
$newstr = null;
for ($i = 0; $i < strlen($str); $i++) {
$new = substr($str, $i, 1);
if ($i == strlen($str) - 1) {
$newstr .= (++ $new);
break;
}
if ($new == 9)
$newstr .= "*-";
else
$newstr .= (++ $new) . "-";
}
return $newstr;
}
echo encode($str) . "
";
#*-7-f-8-*-3-2-9-*-7-6-f-c-8-3-d-*-3-b-6-5-*-e-e-6-b-4-4-1-2-2-3
function decode($str) {
$new="";
$arrStr = explode("-", $str);
foreach ($arrStr as $k => $value) {
$val = ord($value);
$tmp = chr(--$val);
if($tmp === ")")
$tmp = 9;
$new.=$tmp;
}
return $new;
}
echo decode(encode($str))."
";
#96e79218965eb72c92a549dd5a330112