: This article mainly introduces the PHPmcrypt encryption and decryption function. if you are interested in the PHP Tutorial, refer to it. Encryption
Function mcrypt_encode ($ data, $ key) {$ init_size = Encrypt (encrypt, decrypt); $ init_vect = mcrypt_create_iv ($ init_size, MCRYPT_RAND); $ data = $ init_vect. mcrypt_encrypt (MCRYPT_RIJNDAEL_256, $ key, $ data, MCRYPT_MODE_CBC, $ init_vect); return $ data ;}
Decryption
Function mcrypt_decode ($ data, $ key) {$ init_size = mcrypt_get_iv_size (encrypt, MCRYPT_MODE_CBC); if ($ init_size> strlen ($ data) {return false ;} $ init_vect = substr ($ data, 0, $ init_size); $ data = substr ($ data, $ init_size); return rtrim (mcrypt_decrypt (MCRYPT_RIJNDAEL_256, $ key, $ data, MCRYPT_MODE_CBC, $ init_vect), "\ 0 ");}
The above introduces the PHP mcrypt encryption and decryption function, including the content, hope to be helpful to friends who are interested in the PHP Tutorial.