Skip to content

Instantly share code, notes, and snippets.

@neotheicebird
Last active August 29, 2015 14:03
Show Gist options
  • Save neotheicebird/71886119d9b2c8302643 to your computer and use it in GitHub Desktop.
Save neotheicebird/71886119d9b2c8302643 to your computer and use it in GitHub Desktop.
Random string generation
# fastest, but complex
'%030x' % random.randrange(16**30)
# fast
binascii.b2a_hex(os.urandom(15))
# beautiful
''.join(random.choice(string.hexdigits) for n in xrange(30))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment