//动态密匙
function _key($txt){
$encrypt_key = md5('1234567890');
$ctr = 0;
$tmp = '';
for($i = 0; $i < strlen($txt); $i++){
$ctr = $ctr == strlen($encrypt_key) ? 0 : $ctr;
$tmp .= $txt[$i] ^ $encrypt_key[$ctr++];
}
return $tmp;
}
//加密
function _encode($txt){
$tmp = '';
$r = md5(uniqid(rand(), true));
for ($i = 0,$j=strlen($txt); $i < $j; $i++){
$tmp .= ($txt[$i] ^ $r[$i%32]).$r[$i%32];
}
return base64_encode(_key($tmp));
}
//解密
function _decode($txt){
$txt = _key(base64_decode($txt));
$tmp = '';
for ($i = 0; $i < strlen($txt); $i++){
$tmp .= $txt[$i] ^ $txt[++$i];
}
return $tmp;
}
真心求教各位大大,能详细讲解下最好,在线等,在线等等等.... |