Can an MD5-hash begin with a zero? What about SHA-1?
+4
A:
MD5 hash of "a" = 0cc175b9c0f1b6a831c399e269772661
SHA1 hash of "9" = 0ade7c2cf97f75d009975f4d720d1fa6c19f4897
Neb
2010-07-05 14:47:24
+4
A:
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).
GregS
2010-07-05 14:47:39
+3
A:
md5 of a = 0cc175b9c0f1b6a831c399e269772661
<?php echo md5( 'a' ); ?>
Sha1 of i = 042dc4512fa3d391c5170cf3aa61e6a638f84342
<?php echo sha1( 'i' ); ?>
why not :D
ahmet2106
2010-07-05 14:48:27
+5
A:
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
Joey Adams
2010-07-05 14:48:55
+1
A:
In a cryptographic hash, any given bit should be equally likely to be a 0 or a 1 for random inputs.
Chris
2010-07-05 14:58:54
But aren't there sometimes specific output formats associated with a hash algorithm? E.g. DES extended format starts and ends with an underscore.
Lèse majesté
2010-07-05 15:23:52
Sure, but that's not part of the hash itself, it's just markup.
Chris
2010-07-05 16:28:05