@
@
@xrated2013-11-29 01:58:11
Hashing
@xrated, 2013-11-29 01:58:11

Hashing (md5, sha2, whirlpool)?

So. The input data is taken from the database and written to row[]. Next comes the calculation of hashes, and then a question arose. Why from code hash is not equal to hash1? Does it matter what type of data is encrypted?

$whirlpool=$row['whirlpool'];
$sha2=$row['sha2'];
$hash1 = md5(md5($row['whirlpool']).md5($row['sha2'].'1'));
$hash = md5(md5($whirlpool).md5($sha2).'1');

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
papahoolio, 2013-11-29
_

Because they md5($row['sha2'].'1')are md5($sha2).'1'different things.
The hash function from different strings will give different hash sums (well, except for collisions, but we're not looking for them :)). In your case, the last md5 is counted from different lines. Why? The answer is above :)
Replace $hash = md5(md5($whirlpool).md5($sha2).'1');
with $hash = md5(md5($whirlpool).md5($sha2.'1'));and there will be equality.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question