銆€銆€浠g爜濡備笅:
銆€銆€//$input - stuff to decrypt
銆€銆€//$key - the secret key to use
銆€銆€function do_mencrypt($input, $key)
銆€銆€{
立即学习“PHP免费学习笔记(深入)”;
銆€銆€$input = str_replace(""n", "", $input);
銆€銆€$input = str_replace(""t", "", $input);
銆€銆€$input = str_replace(""r", "", $input);
銆€銆€$key = substr(md5($key), 0, 24);
銆€銆€$td = mcrypt_module_open('tripledes', '', 'ecb', '');
銆€銆€$iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
銆€銆€mcrypt_generic_init($td, $key, $iv);
銆€銆€$encrypted_data = mcrypt_generic($td, $input);
銆€銆€mcrypt_generic_deinit($td);
銆€銆€mcrypt_module_close($td);
銆€銆€return trim(chop(base64_encode($encrypted_data)));
銆€銆€}
銆€銆€//$input - stuff to decrypt
銆€銆€//$key - the secret key to use
銆€銆€function do_mdecrypt($input, $key)
銆€銆€{
立即学习“PHP免费学习笔记(深入)”;
銆€銆€$input = str_replace(""n", "", $input);
銆€銆€$input = str_replace(""t", "", $input);
銆€銆€$input = str_replace(""r", "", $input);
銆€銆€$input = trim(chop(base64_decode($input)));
銆€銆€$td = mcrypt_module_open('tripledes', '', 'ecb', '');
銆€銆€$key = substr(md5($key), 0, 24);
銆€銆€$iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
銆€銆€mcrypt_generic_init($td, $key, $iv);
銆€銆€$decrypted_data = mdecrypt_generic($td, $input);
銆€銆€mcrypt_generic_deinit($td);
銆€銆€mcrypt_module_close($td);
銆€銆€return trim(chop($decrypted_data));
銆€銆€}
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号