Created
March 30, 2012 23:55
-
-
Save mahmoud/2257979 to your computer and use it in GitHub Desktop.
randomness detection (y'know, not really)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# test a supposedly random string (encrypted or hashed or something) for 50% 1s vs 0s | |
mypass = '\xf8\x16\x01-\xfd3\xf7\x06\xbf\xc4\x1eU=\xc0\xe8a\xf4\xa0\x8b\xd0' | |
x = ''.join(["{0:08b}".format(ord(a)) for a in mypass]) | |
print x.count('0')/(len(x)+0.0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment