Last active
July 14, 2016 14:32
-
-
Save rudyryk/6102448 to your computer and use it in GitHub Desktop.
Python os.urandom example: make random password
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
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