1. SHA1(安全哈希算法1):
SHA1是由美国国家安全局设计的加密哈希函数。它需要一个输入并产生一个160位的哈希值。此外,此函数产生的输出将转换为40位长的十六进制数。它是美国联邦信息处理标准。它于1995年首次发布。它是1993年发布的SH0的后继产品。
例子:
Data : Geeksforgeeks
SHA1 : bc7623b7a94ed3d8feaffaf7580df3eca4f5f5ca
2. SHA2(安全哈希算法2):
SHA1也是由美国国家安全局设计的加密哈希函数。它是通过单向压缩函数使用Merkle-Damgard结构构造的。所使用的压缩函数是使用Davies-Meyer结构根据分类的分组密码构造的。它于2001年首次发布。它是SH1的后继产品。
例子:
Data : Geeksforgeeks
SHA2(256) : 86d755349c6b9f95f365c6ffe7734f25bf2b00cabe8c6bc5f2b8b746c1aac332
SHA1和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. |