SHA-2 is a secure hashing algorithm developed by National Institute of Standards and Technology (NIST). It can generate a fixed-length hash value for any input data, which is difficult to forge.
SHA-2 consists of five hash functions with different lengths, namely SHA-224, SHA-256, SHA-384, SHA-5 12, SHA-5 12/224 and SHA-5 12/256. Where "SHA" stands for secure hash algorithm and "number" stands for the number of digits of the output hash value.
The hash length of SHA-2 algorithm is 224,256,384,512 bits, which are 28 bytes, 32 bytes, 48 bytes and 64 bytes respectively. Among them, SHA-224 and SHA-256 are 160 rounds of variable operation and constant calculation based on 32-bit words.
SHA-384, SHA-5 12, SHA-5 12/224, SHA-5 12/256 are 80 rounds of variable operation and constant calculation based on 64-bit words. Each round of operation will get an intermediate value, which will be used in the next round of operation to generate a new intermediate value. Finally, all the intermediate values are added to form the output hash value.
In addition to the length of the output hash value, other important parameters of SHA-2 algorithm include filling method, initial value and constants in the operation process. The filling method mainly includes dividing the input message into multiple blocks and filling each block to ensure that the length of the message is equal to the grouping length of the algorithm.
The initial value is a constant, which is used to specify the initial state agreed by both parties at the beginning of the algorithm. The constant in the encryption process is a numerical value determined in the algorithm, which is used to disturb the input data and increase the difficulty of encryption.
The security of SHA-2 algorithm has been widely recognized, and it has been widely used in digital signature, identity authentication, message authentication and other fields. However, with the continuous improvement of computer computing power and the development of password attack technology, the security of SHA-2 is increasingly questioned. Therefore, SHA-3 is considered as a supplement to SHA-2 algorithm, aiming at providing higher security and better performance.