Is it possible to retrieve the original message from a SHA-1 encrypted message? If I have an SHA -1 encrypted message, what all paratmeters do i need to get the original message from it?
-
not easily, there is no decrypt for it... to decrypt you would need to have the equivalent of rainbow tables to sha-1 --- a very time and computationally expensive operation – hackartist Jun 11 '12 at 04:58
5 Answers
I answered a similar question already: Python SHA1 DECODE function
In short, no it is not possible. The whole point of hashing is to take some long string and turn it into a small one. Hashing is destructive and you lose data, so it is irreversible.
Also, to make things more fun, infinitely many strings have the same hash1. It is impossible to generate a unique string with a given hash unless you know more information about the input.
1: There are tons of hash functions and some may have "special" hashes that are only generated when you give a specific input to the function. Aside from those rare cases (if they even exist), every other output hash has infinitely many input strings.
http://en.wikipedia.org/wiki/Cryptographic_hash_function
it is infeasible to generate a message that has a given hash
- 565
- 5
- 13
-
1That's from the description of the "ideal" hash function, which doesn't exist. There has been some recent fuss about the MD5 cryptographic hash function is because it has turned out **not** to be infeasible to generate a message that has a given hash - not the original message, but an alternative that says what the attacker wants it to say. The same may one day happen to SHA-1. – Jun 11 '12 at 05:23
The SHA-1 hash generate a 160-bit output from an arbitrarily sized input. As there is more possible inputs than the 2^160 possible output, there is bound to be collision, ie. different input having the same output.
This mean that it may be possible (via brute-force or by exploiting a weakness in the algorithm — none are known at the moment I think) to find a message corresponding to a given hash, but it may not be the original message.
Even if you fix the size of the input, if it is larger than 160 bits, there will be collision, and no way to invert the hash function.
- 42,429
- 12
- 75
- 85
Hashing is not encryption. Encryption is like shuffling the pieces of a jigsaw puzzle. Hashing is more like putting the pieces in a blender, there's no reasonable way to restore the original picture after that.
- 4,978
- 2
- 21
- 41
If you know the length of the original message (in multiples of 512 bits), you'll only need to test the 2^512 inputs of that size. Apply a SHA1 operation to each, and compare the result. This assumes no salting, and rather significant computational resources.
- 326
- 3
- 13