Python SHA1 DECODE function

主宰稳场 提交于 2019-12-01 14:48:20

SHA1 is a hashing algorithm. Hashing is one-way, which means that you can't recover the input from the output for any non-trivial hash function. A simple example of a one-way hash function would be adding together all the digits of a number. 1234 would hash to 1 + 2 + 3 + 4 = 10, but so would 4321, 1900, 5050, and many other numbers. Given just the hash value of 10, you can't tell whether the input was 1234 or 5050 because information was lost.

Here's a graphical example:

As you can see, both John Smith and Sandra Dee are mapped to 02. This means that you can't recover which name was hashed given only 02.

Hashing is useful because it maps any amount of data to a fixed-size output and, unlike in the above examples, it is extremely difficult to find two inputs that hash to the same output. It took over 6,500 CPU-years to find just a single pair inputs to SHA-1 that have the same hash.

Therefore, if hash(A) == hash(B), then you can be confident that A == B. If you copy a huge file and the hashes of both the original and the copy are the same, then you can be pretty sure that the file is intact.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!