Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to test if two sha2 hashes came from the same plain text?

The following are both SHA256 hashes of an empty string, generated with PHP's crypt function.

$5$fooooooooooooooo$Y6IVN.cYkABQ4h8dCR0zL/rJoRx09pwMoGaYST9HqDD
$5$baaaaaaaaaaaaaar$C84IKQdPMG8qvnnckGZsyBJWKHuaSD0tqcmyueHI0GA

Each was generated with a different 16 bytes of salt present in the hash. Is there a way to merely test that they are hashes of the same thing, without knowing what that thing was?

like image 294
Tim Avatar asked Dec 08 '10 16:12

Tim


People also ask

Is SHA hash always the same?

Yes, if you hash the same input with the same function, you will always get the same result. This follows from the fact that it is a hash-function.

Are hash functions always one-way?

While there are many types of two-way encryption, hash functions are one-way encryption, which makes them even tougher codes to crack.

Why is a hash only one-way?

Furthermore, a one-way hash function is designed in such a way that it is hard to reverse the process, that is, to find a string that hashes to a given value (hence the name one-way.) A good hash function also makes it hard to find two strings that would produce the same hash value.

Is it possible to reverse a hash?

You can't reverse hashing functions: they are not a form of encryption. That's why hashes are always the same length regardless of the input length: they throw away information in order to generate a (hopefully) unique value from the input.


2 Answers

No. The strings become completely unique once the salts are added, and there is no way of reversing a hashed string.

like image 136
simshaun Avatar answered Sep 20 '22 00:09

simshaun


No. You could only do that if the same salt was used.

like image 27
John Christensen Avatar answered Sep 21 '22 00:09

John Christensen