Can an MD5-hash begin with a zero?

2020-07-06 02:38发布

问题:

Can an MD5-hash begin with a zero? What about SHA-1?

回答1:

Yes:

$ echo -n "363" | md5sum
00411460f7c92d2124a67ea0f4cb5f85  -
$ echo -n "351" | sha1sum
0026476a20bfbd08714155bb66f0b4feb2d25c1c

Found by running the following in bash:

for i in  {1..1000} ; do echo $(echo -n $i | md5sum) $i ; done | sort | head


回答2:

I found a MD5 hash that beginns with a zero byte!
2 character String

Unicode #7358 #34823

$returnValue = md5('Ჾ蠇');

result:

00000000 5e0a51c8 313ffb43 8a3a2861


回答3:

Of course. Or two zeros. Or more. In general, the probability of a "random" input hashing to a result with k leading zero nybbles is about 2-4k.



回答4:

Try with the string : jk8ssl

echo md5('jk8ssl')

generate :

00000000 18e6137a c2caab16 074784a6

I didn't find better yet ^^



回答5:

MD5 hash of "a" = 0cc175b9c0f1b6a831c399e269772661

SHA1 hash of "9" = 0ade7c2cf97f75d009975f4d720d1fa6c19f4897



回答6:

md5 of a = 0cc175b9c0f1b6a831c399e269772661

<?php echo md5( 'a' ); ?>

Sha1 of i = 042dc4512fa3d391c5170cf3aa61e6a638f84342

<?php echo sha1( 'i' ); ?>

why not :D



回答7:

In a cryptographic hash, any given bit should be equally likely to be a 0 or a 1 for random inputs.



回答8:

This thread is pretty old now, but there are some very high & very low value hashes for SHA1 and MD5 here:

https://web.archive.org/web/20171201071711/http://www.crysys.hu/hashgame/allrecord.php

One of those has 7 bytes of leading zeros.



标签: md5 zero