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. |
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
Recommended Posts:
- Difference between MD5 and SHA1
- Difference between MP4 and MP3
- Difference between PCI and PCI-X
- Difference between PCI-E and PCI-X
- Difference between IBM DB2 and MS SQL
- Difference between 1G and 2G
- Difference between Tor and VPN
- Difference between USB 2.0 and USB 3.0
- Difference between H.323 and SIP
- Difference Between Gi-Fi and Li-Fi
- Difference between CRT and LCD
- Difference between DFD and ERD
- Difference between T-SQL and PL-SQL
- Difference between SSH and SSL
- Difference Between SEO and SEM
- Difference between AIX and QNX
- Difference between TDM and FDM
- Web 1.0, Web 2.0 and Web 3.0 with their difference
- Difference between AIX and IBM i
- Difference between MAN and WAN
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

