Skip to content

Instantly share code, notes, and snippets.

@rudyryk
Last active July 14, 2016 14:32
Show Gist options
  • Save rudyryk/6102448 to your computer and use it in GitHub Desktop.
Save rudyryk/6102448 to your computer and use it in GitHub Desktop.
Python os.urandom example: make random password
import os
def make_random_password(length=12, symbols='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@$^_+&'):
password = []
for i in map(lambda x: int(len(symbols)*x/255.0), os.urandom(length)):
password.append(symbols[i])
return ''.join(password)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment