Home >Backend Development >PHP7 >What are the differences between DES, ECB and CBC encryption methods?
In php, there are several encryption methods, including DES, ECB and CBC. Today I will take you to understand the differences between these three encryption methods. You can refer to them if necessary.
ECB mode:
Advantages:
1. Simple;
2. Conducive to parallel computing;
3. Errors will not be transmitted;
Disadvantages:
1. Unable to hide plaintext patterns;
2. Possible Actively attack plaintext;
DES ECB (electronic secret book method) is actually very simple. It is to DES encrypt or decrypt the data into 8-byte segments to obtain 8-byte ciphertext segments or Plain text, the last paragraph is less than 8 bytes (generally supplemented with 0 or F), supplement 8 bytes according to the requirements for calculation (parallel calculation), and then connect the calculated data together in order, between each piece of data Do not affect each other.
CBC mode:
Advantages:
1. Not easy to attack actively, more secure than ECB, it is the standard of SSL and IPSec;
Disadvantages:
1. Not conducive to parallel computing;
2. Error propagation;
3. Requires initialization vector IV;
DES CBC mode
(ciphertext group linking method) is a bit troublesome. Its implementation mechanism makes the various pieces of encrypted data related. The implementation mechanism is as follows:
The encryption steps are as follows:
1. First, group the data into groups of 8 bytes to obtain D1D2...Dn (if the data is not 8 An integer multiple of the value, fill the bits with the specified PADDING data)
2. The result of the XOR of the first set of data D1 and the initialization vector I is DES encrypted to obtain the first set of ciphertext C1 (the initialization vector I is the full Zero)
3. The second set of data D2 is XORed with the first set of encryption results C1 and the result is DES encrypted to obtain the second set of ciphertext C2
4. By analogy, we get Cn
5. Connect in sequence as C1C2C3...Cn is the encryption result.
This is the working mode of block cipher CBC is the password block chain mode ECB is the code book mode
Recommended learning: php video tutorial
The above is the detailed content of What are the differences between DES, ECB and CBC encryption methods?. For more information, please follow other related articles on the PHP Chinese website!