How to use the Mcrypt extension library for encryption and decryption. Summary: Mcrypt2.4.7 is a powerful Extension Library for encryption algorithms. It includes 22 algorithms, including the following algorithms :???? BlowfishRC2Safer-sk64xtea ???? Cast-256 Summary: Mcrypt 2.4.7 is a powerful Extension Library for encryption algorithms. It includes 22 algorithms, including the following algorithms :???? Blowfish RC2 Safer-sk64 xtea ???? Cast-256 RC4 Safer-sk128 ???? DES RC4-iv Serpent ???? Enigma Rijndael-128 Threeway ???? Gost Rijndael-192 TripleDES ???? LOKI97 Rijndael-256 Twofish ???? PanamaSaferplus Wake ?? How to install Mcrypt? ?? Mcrypt is not included in the standard PHP package, so you need to download it at: ftp://argeas.cs-net.gr/pub/unix/mcrypt. After the download, follow the following method to compile and expand it to PHP :?? Download the Mcrypt package.
???? Gunzipmcrypt-x.x.x.tar.gz ???? Tar -xvfmcrypt-x.x.x.tar ????. /Configure -- disable-posix-threads ???? Make ???? Make install ???? Cd to your PHP directory .????. /Configure-with-mcrypt = [dir] [-- other-configuration-directives] ??? Make ???? Make install ?? Make appropriate modifications to the server during PHP installation according to your requirements.
?? How to use the Mcrypt Extension Library to encrypt data? ?? First, we will introduce how to use the Mcrypt Extension Library to encrypt data, and then how to use it for decryption. The following code demonstrates this process. first, encrypt the data, display the encrypted data in the browser, and restore the encrypted data to the original string, display it in a browser.
?? Use Mcrypt to encrypt and decrypt data ???? ";???? $ Decrypted_string = mcrypt_decrypt ($ cipher_alg, $ key ,???? $ Encrypted_string, MCRYPT_MODE_CBC, $ iv );???? Print "Decrypted string: $ decrypted_string"; ???> ?? Executing the above script will generate the following output :???? Original string: Applied Cryptography, by Bruce Schneier, is a wonderful cryptography reference .???? Encrypted string: 201734fa06bbfb20e71ecf525f29df58e28f3d9bf541f7ebcecf62b 108bfbab5e ???? Decrypted string: Applied Cryptography, by Bruce Schneier, is a wonderful cryptography reference .?? The two most typical functions in the above code are mcrypt_encrypt () and mcrypt_decrypt (). Their usage is obvious. We use the "Telegraph cipher book" mode. Mcrypt provides several encryption methods. because each encryption method has specific characters that can affect the password security, we need to understand each mode. For those who have no access to the password system, why? The crypt_create_iv () function is more interested. we will mention the initialization vector (hence, iv) it creates, which can always make each piece of information independent of each other.
Although not all modes require this initialization variable, PHP will give a warning if this variable is not provided in the required mode.
Ipv2.4.7 is a powerful extension library of encryption algorithms. It includes 22 algorithms, including the following algorithms :???? Blowfish RC2 Safer-sk64 xtea ???? Cast-256...