代碼如下:
//$input
//$key
function do_mencrypt($input
{
$input = str_replace(""n"
$input = str_replace(""t"
$input = str_replace(""r"
$key = substr(md
$td = mcrypt_module_open(
$iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td)
mcrypt_generic_init($td
$encrypted_data = mcrypt_generic($td
mcrypt_generic_deinit($td);
mcrypt_module_close($td);
return trim(chop(base
}
//$input
//$key
function do_mdecrypt($input
{
$input = str_replace(""n"
$input = str_replace(""t"
$input = str_replace(""r"
$input = trim(chop(base
$td = mcrypt_module_open(
$key = substr(md
$iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td)
mcrypt_generic_init($td
$decrypted_data = mdecrypt_generic($td
mcrypt_generic_deinit($td);
mcrypt_module_close($td);
return trim(chop($decrypted_data));
}
From:http://tw.wingwit.com/Article/program/PHP/201311/21012.html