Is any substring of a hash (md5, sha1) more "random" than another? -


here's 3 example md5 hashes

$ md5 -s "1" && md5 -s "2" && md5 -s "3" md5 ("1") = c4ca4238a0b923820dcc509a6f75849b md5 ("2") = c81e728d9d4c2f636f067f89cc14862c md5 ("3") = eccbc87e4b5ce2fe28308fd9f2a7baf3 

say wanted take 8 characters hash. beginning part of hash particularly more "random" end? middle? or substrings equally "random"?

i curious myself, went ahead , wrote program test this. you'll need crypto++ compile code.

disclaimer: when comes cryptography, or mathematics in general, know enough shoot myself in foot. so, take following results grain of salt , keep in mind have cursory knowledge of tools i'm using.

i sampled 3 substrings: first 8 bytes, middle 8 bytes, , last 8 bytes. long story short, they're equally random.

however, when using smaller sample space, appears if last 8 bits more random. larger sampling space, closer 3 substrings approach complete randomness.


1000 iterations:

first:  0.995914 middle: 0.996546 last:   0.998104 

5000 iterations:

first:  0.998387 middle: 0.998624 last:   0.999501 

10000 iterations:

first:  0.999614 middle: 0.999457 last:   1 

30000 iterations:

first:  1 middle: 1 last:   1 

"randomness" measured crypto++'s maurerrandomnesstest class. reference, executable compiled above code has randomness value of 0.632411 , copy of shakespeare's macbeth downloaded project gutenburg has randomness value of 0.566991.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

linq to sql - Linq2EF: Return DateTime with a TimeZone Offset -

gdi+ - WxWidgets draw a bitmap with opacity -