Mcrypt reversible encryption algorithm in PHP
$TD = Mcrypt_module_open (Mcrypt_des, ', ' ECB ', '); Using the mcrypt_des algorithm, the ECB mode
$iv = Mcrypt_create_iv (Mcrypt_enc_get_iv_size ($TD), Mcrypt_rand);
$ks = Mcrypt_enc_get_key_size ($TD);
$key = "ery secret key";//Key
$key = substr (MD5 ($key), 0, $ks);
Mcrypt_generic_init ($TD, $key, $IV); Initial processing
Encryption
$encrypted = Mcrypt_generic ($TD, ' This is very important data ');
End Processing
Mcrypt_generic_deinit ($TD);
Initial decryption processing
Mcrypt_generic_init ($TD, $key, $IV);
Decrypt
$decrypted = Mdecrypt_generic ($TD, $encrypted);
End
Mcrypt_generic_deinit ($TD);
Mcrypt_module_close ($TD);
After decryption, there may be a follow-up that needs to be removed
echo Trim ($decrypted). "N";
http://www.bkjia.com/PHPjc/629707.html www.bkjia.com true http://www.bkjia.com/PHPjc/629707.html techarticle Mcrypt reversible encryption algorithm in PHP? php tutorial $td = Mcrypt_module_open (Mcrypt_des, ', ' ECB ', ');//using mcrypt_des algorithm, ECB mode $IV = Mcrypt_ Create_iv (mcrypt_enc_get_iv_size ($t ...