# Encrypt Text

## An online text encryption tool that provides MD5, SHA, AES decryption and AES encryption functions.

## The importance of data encryption

Data encryption can improve data security, so that even if the data is stolen, hackers cannot directly access the data, thereby reducing the risk of data leakage and loss.

## MD5 encryption algorithm

MD5 encryption is a commonly used hash function for compressing information of any length into 128 bits (16 bytes) of data. It was designed by American cryptographer Ron Rivest in 1991 and has become one of the widely used encryption algorithms.

The core idea of the MD5 algorithm is to convert the original data into a fixed-length information digest through multiple hash operations. Specific steps are as follows:

Padding data: pad the original data so that its length satisfies 448 modulo 512, that is, n * 512 + 448, where n is a non-negative integer.

Add length: Add a 64-bit length value at the end of the padded data, indicating the length of the original data. Because the MD5 algorithm only supports input data whose length does not exceed 2^64, the length value needs to be expressed in 64 bits.

Initialize variables: define four 32-bit registers A, B, C, D, and a 64-bit constant array T.

Processing packet data: Divide the filled data into 512-bit packets, and process one packet at a time. For each group, 4 rounds of cycles are performed, and each cycle includes 4 steps: F, G, H, I.

a. F function: The three registers B, C, and D are used as input, and a 32-bit result is generated after a series of bit operations and nonlinear functions.

b. G function: The three registers C, D, and A are used as input, and a 32-bit result is generated after a series of bit operations and nonlinear functions.

c. H function: The three registers D, A, and B are used as input, and a 32-bit result is generated after a series of bit operations and nonlinear functions.

d. I function: take the three registers C, B, and A as input, and produce a 32-bit result after a series of bit operations and nonlinear functions.

Combined results: The results of the four registers are concatenated in order to obtain a 128-bit hash value.

Through the above steps, the MD5 algorithm can compress data of any length into a 128-bit hash value, which is irreversible and unique. Therefore, MD5 encryption is widely used in data integrity verification, digital signature, password protection, etc. However, since the MD5 algorithm has security loopholes and is vulnerable to collision attacks and pre-mapping attacks, it is necessary to use a more secure encryption algorithm in scenarios with high security requirements.

## SHA encryption algorithm

SHA (Secure Hash Algorithm) is an encryption algorithm that can convert data (messages) of arbitrary length into fixed-length hash values, and is usually used to ensure data integrity and security. The SHA algorithm was developed by the US National Security Agency (NSA), and there are currently several versions, the more popular of which are SHA-1, SHA-2, and SHA-3.

SHA-1 (Secure Hash Algorithm 1) is one of the earliest widely used versions of the SHA algorithm, which converts a message of any length into a 160-bit hash value. SHA-2 includes four variants of SHA-224, SHA-256, SHA-384, and SHA-512, which convert messages into 224-bit, 256-bit, 384-bit, and 512-bit hashes, respectively. SHA-3 is the latest version of the SHA algorithm, which converts messages into fixed-length hash values. Unlike SHA-2, the design of the SHA-3 algorithm is based on the Keccak algorithm.The encryption principle of the SHA algorithm can be briefly summarized as the following steps:1. Data preprocessing (Padding): The SHA algorithm first pads the input data to make its length meet the requirements of the algorithm. The specific filling method is related to the algorithm version.2. Initial Hash Values: The SHA algorithm sets a fixed initial hash value as a constant.3. Message grouping: The SHA algorithm divides the input data into multiple fixed-length message blocks (512 bits). After each message block undergoes a series of calculations, a 256-bit hash value will be obtained.4. Iterative calculation of hash value: The SHA algorithm will use the hash value of the previous message block as the input of the next message block, and perform iterative calculation until the hash values of all message blocks are calculated.5. Output: The SHA algorithm finally combines the hash values of all message blocks to generate a final hash value as output.Since the length of the hash value of the SHA algorithm is fixed and very large, the SHA algorithm has high security and irreversibility, and can be used for data integrity verification, digital signature and other security applications.

## AES encryption algorithm

AES (Advanced Encryption Standard) is an advanced encryption standard, also known as the Rijndael algorithm, and is one of the most widely used symmetric encryption algorithms at present. The AES encryption algorithm uses the same key to encrypt and decrypt data and is therefore classified as a symmetric encryption algorithm.

The principle of AES encryption can be briefly summarized as the following steps:

1. Key Expansion: The AES algorithm first needs to expand the input key into a large key array, which is used for subsequent encryption and decryption operations.

2. Initial round (Initial Round): The AES algorithm performs a series of preprocessing on the input data, including chunking the input data, adding round keys, byte substitution, and row shifting.

3. Rounds: The AES algorithm uses multiple rounds of iterations for encryption operations, and each round of iterations includes four steps: byte substitution, row shifting, column confusion, and adding round keys.

4. Final Round: The AES algorithm performs special processing on the last data block, including byte substitution, row shifting, and round key addition.

5. Output: The AES algorithm outputs the encrypted data block as ciphertext, and the decryption operation inputs the ciphertext into the AES algorithm for decryption.

In the AES algorithm, the encryption and decryption operations are reversible, and the encrypted data can be decrypted using the same key. The AES algorithm provides three key lengths: 128 bits, 192 bits, and 256 bits. The longer the key length, the higher the security of the algorithm.

The AES algorithm has high security and efficiency, and is widely used in various security scenarios, such as encrypted data transmission, encrypted file storage, digital signature, etc.

## AES decryption algorithm

The algorithm to decrypt AES-encrypted data is the same as the encryption algorithm, except that the key is used differently.

Here are the steps to decrypt AES encrypted data using the key:

1. Get AES encrypted data and key.

2. Group keys by key length, for example a 128-bit key will be divided into four 32-bit words.

3. Determine the number of rounds required based on the key length. For example, using a 128-bit key requires 10 rounds, a 192-bit key requires 12 rounds, and a 256-bit key requires 14 rounds.

4. Use the key to decrypt encrypted data. The decryption process includes multiple steps, the most important of which are round key addition, byte substitution, row shifting, and column obfuscation.

5. Repeat the decryption process for several rounds.

6. Perform a final round of decryption, but omit the column obfuscation step.

7. Finally, the decrypted data is obtained.

It should be noted that the key length used by the AES encryption algorithm must be one of 128 bits, 192 bits or 256 bits. Therefore, when using the AES decryption algorithm, a key with the same length as the encryption algorithm must be used to correctly decrypt the data.

File size exceeds limit.

You can not upload any more files.