MCrypt encoding function library: MCRYPT_CBC

Source: Internet
Author: User
Keywords mcrypt mcrypt_cbc php Chinese function manual coding function Library
Tags aliyun coding coding function library data function function library html http

Mcrypt_cbc

Use CBC to add/decrypt data.

Syntax: string MCRYPT_CBC (int cipher, string key, string data, int mode, string [IV]);

return value: String

Function type: Encoding processing
&http://www.aliyun.com/zixun/aggregation/37954.html ">NBSP;
Content Description

This function encrypts and decrypts the data using CBC Password retrieval (cipher block chaining). parameter cipher to add/decrypt method, such as Mcrypt_tripledes. Parameter key is the key to the password, of course, keep it confidential. The string to encrypt or decrypt is placed in parameter data. Parameter mode indicates the encryption Mcrypt_encrypt or decryption mcrypt_decrypt. Parameter IV is an omitted parameter representing vector initialization (initialization vector, IV).

To use this function library to prepare the MCrypt program, you can download the program to Ftp://argeas.cs-net.gr/pub/unix/mcrypt libmcrypt-x.x.tar.gz. At the same time in compiling PHP program needs to add--with-mcrypt options, so that the function library to operate smoothly.
This function provides the encoding of DES, TripleDES, Blowfish (default), 3-way, safer-sk64, safer-sk128, Twofish, tea, RC2, and the use of CBC, OFB, CFB, and ECB for password retrieval GOST. In addition, RC6 and idea are not free coding methods. See listed below as defined passwords:

Mcrypt_blowfish
Mcrypt_des
Mcrypt_tripledes
Mcrypt_threeway
Mcrypt_gost
Mcrypt_crypt
Mcrypt_des_compat
Mcrypt_safer64
mcrypt_safer128
mcrypt_cast128
Mcrypt_tean
Mcrypt_rc2
Mcrypt_twofish (before MCRYPT 2.x version)
mcrypt_twofish128 (MCRYPT 2.x version)
mcrypt_twofish192
mcrypt_twofish256
Mcrypt_rc6
Mcrypt_idea

In the area of password retrieval (cipher), this library supports four cipher searches of CBC, OFB, CFB and ECB. The simple description of these four cipher searches is as follows, please refer to Schneier's Applied Cryptography (ISBN:0-471-11709-9) For more detailed information:

ECB (Electronic codebook): Suitable for random data, such as using another key. Using the ECB is less appropriate if the volume of data is small and random.
CBC (cipher block Chaining): For file encryption, security is better than the ECB.
CFB (cipher feedback): Suitable for encrypting a segment of independent bit data (single bytes) in a bit-group stream.
OFB (output feedback): Compatible with CFB, especially for applications that cannot tolerate error ripple.
PHP is still unable to encrypt the unit (bit) entropy to decrypt the steps, currently only suitable for the string for password processing.

When using the two modes of CFB and OFB, vector initialization (initialization vector, IV) is required, and the CBC mode can also be initialized using vectors. The value of the vector initialization must be unique and remain the same while decrypting. When the data output is encrypted, the password key can also be output simultaneously (for example, in a file), or the value initialized by the vector can be exported with the encrypted data.

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.