Created
December 2, 2013 22:33
-
-
Save calroc/7760312 to your computer and use it in GitHub Desktop.
A simple and straightforward password generator that produces alphanumeric random strings of length ten omitting those characters that are easily confused with each other in various fonts. Ensures at least one character will be a numeral.
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
#!/usr/bin/env python | |
from string import letters, digits | |
from random import choice | |
# Get a list of unambiguous ASCII characters. (It must be a list as | |
# sets don't work with random.choice().) | |
chars = list(set(letters + digits) - set('oO0I1lB8S5b6')) | |
def _pwgen(n=10): | |
return ''.join(choice(chars) for _ in range(n)) | |
def pwgen(n=10): | |
pw = '' | |
while not any(ch in digits for ch in pw): | |
pw = _pwgen(n) | |
return pw | |
if __name__ == '__main__': | |
print pwgen() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment