I cant find how to decode string encoded in sha1. I\'m suprised that i can\'t find simple function in python docs or google doing sha1 decoding. I give up. I need help..
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.