📜  SHA1 和 SHA2 的区别

📅  最后修改于: 2021-09-28 11:00:25             🧑  作者: Mango

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.