在功能上需要關鍵不mcrypt的libraly在PHP如何在PHP中沒有的mcrypt庫加密字符串
function encrypt($str, $pass){
$str_arr = str_split($str);
$pass_arr = str_split($pass);
$add = 0;
$div = strlen($str)/strlen($pass);
while ($add <= $div) {
$newpass .= $pass;
$add++;
}
$pass_arr = str_split($newpass);
foreach($str_arr as $key =>$asc) {
$pass_int = ord($pass_arr[$key]);
$str_int = ord($asc);
$int_add = $str_int + $pass_int;
$ascii .= chr($int_add);
}
return $ascii;
}
function decrypt($enc, $pass){
$enc_arr = str_split($enc);
$pass_arr = str_split($pass);
$add = 0;
$div = strlen($enc)/strlen($pass);
while ($add <= $div) {
$newpass .= $pass;
$add++;
}
$pass_arr = str_split($newpass);
foreach($enc_arr as $key =>$asc) {
$pass_int = ord($pass_arr[$key]);
$enc_int = ord($asc);
$str_int = $enc_int - $pass_int;
$ascii .= chr($str_int);
}
return $ascii;
}
在這個加密字符串我性格不行我測試了
你說什麼?需要此問題的更多信息。 – 2009-04-29 04:52:12