Skip to content

Instantly share code, notes, and snippets.

@mahmoud
Created March 30, 2012 23:55
Show Gist options
  • Save mahmoud/2257979 to your computer and use it in GitHub Desktop.
Save mahmoud/2257979 to your computer and use it in GitHub Desktop.
randomness detection (y'know, not really)
# 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