How to mcrypt the extension library for encryption and decryption _php tutorial

Source: Internet
Author: User
Tags mcrypt
Summary: Mcrypt 2.4.7 is a powerful cryptographic algorithm extension library that 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 it needs to be downloaded and the download address is: ftp://argeas.cs-net.gr/pub/unix/mcrypt/. After downloading, follow the methods below to compile and expand it in 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 the appropriate modifications to your request and to the server when installing PHP.
?? How do I encrypt data using the MCrypt extension library??? First, we'll show you how to encrypt the data using the MCrypt extension library, and then explain how to use it for decryption. The following code demonstrates this process by encrypting the data, then displaying the encrypted data on the browser and restoring the encrypted data to the original string and displaying it on the browser.
?? Use MCrypt to add 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 produce the following output:???? Original string:applied cryptography, by Bruce Schneier, is a wonderful cryptography reference. ???? Encrypted string:02a7c58b1ebd22a9523468694b091e60411cc4dea8652bb8072 34fa06bbfb20e71ecf525f29df58e28f3d9bf541f7ebcecf62b C89fde4d8e7ba1e6cc9ea24850478c11742f5cfa1d23fe22fe8 bfbab5e???? 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 (), whose purpose is obvious. We use the "Telegraph cipher" mode, MCrypt provides several encryption methods, because each encryption method can affect the password security of certain characters, so for each mode need to understand. For those readers who have not contacted the password system, the allowance du Crypt_create_iv () function is more interesting, and we will mention the initialization vectors it created (hence, iv), which has always allowed each piece of information to be independent of each other.
Although not all patterns require this initialization variable, PHP gives a warning message if the variable is not provided in the required pattern.

http://www.bkjia.com/PHPjc/631053.html www.bkjia.com true http://www.bkjia.com/PHPjc/631053.html techarticle Summary: Mcrypt 2.4.7 is a powerful cryptographic algorithm extension library that includes 22 algorithms, including the following algorithms:???? Blowfish RC2 safer-sk64 Xtea???? Cast-256 ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.