Difference between SHA1 and SHA2
Last Updated :
22 May, 2020
1. SHA1 (Secure Hash Algorithm 1) :
SHA1 is a cryptographic hash function which is designed by United States National Security Agency. It takes an input and produces a 160 bits hash value. Further the output produced by this function is converted into a 40 digits long hexadecimal number. It is a U.S. Federal Information Processing Standard. It was first published in 1995. It is successor to SH0 published in 1993.
Example:
Data : Geeksforgeeks
SHA1 : bc7623b7a94ed3d8feaffaf7580df3eca4f5f5ca
2. SHA2 (Secure Hash Algorithm 2) :
SHA1 is also a cryptographic hash function which is designed by United States National Security Agency. It is constructed using the Merkle-Damgard structure from a one-way compression function. The compression function used is constructed using the Davies-Meyer structure from a classified block cipher. It was first published in 2001. It is successor to SH1.
Example:
Data : Geeksforgeeks
SHA2(256) : 86d755349c6b9f95f365c6ffe7734f25bf2b00cabe8c6bc5f2b8b746c1aac332
Difference between SHA1 and SHA2 :
SHA1 |
SHA2 |
It is a cryptographic hash function designed by U.S National Security Agency to replace SH0. |
It is a cryptographic hash function designed by U.S National Security Agency to replace SH1. |
It was published in 1995. |
While it was published in 2001. |
It produces 160 bits hash value. |
It produces 224, 256, 384 or 512 bits hash value. |
It is successor to SH0 and predecessor to SH2. |
It is successor to SH1 and predecessor to SH3. |
It is less secure. |
While it is more secure. |
Its structure is based on Merkle–Damgard construction. |
Its structure is based on Merkle–Damgard structure with Davies–Meyer compression function. |
SHA1 certificates are not reliable. |
SHA2 has more improved certificates. |
It generates smaller hash. |
While it generates larger hash. |
Hash generated by SHA1 is weak. |
While hash generated by SHA2 is strong. |
It is not widely used now-a-days. |
While it is used widely. |
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...