Created
January 16, 2012 09:20
-
-
Save aksiksi/1619961 to your computer and use it in GitHub Desktop.
Generates a number of random passwords of chosen length and outputs them to a file.
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
from random import choice | |
types = [ | |
map(chr, range(97, 123)), | |
map(chr, range(65, 91)), | |
range(0, 10) | |
] | |
def password_gen(length): # Generates a random password | |
password = [] | |
for char in range(1, length+1): | |
password.append(choice(choice(types))) | |
return ''.join(map(str, password)) | |
length = int(raw_input("Enter pass length please: ")) | |
number = int(raw_input("Enter number of passwords to generate: ")) | |
f = open('passwords.txt', 'w') | |
for a in range(1, number+1): | |
f.write(password_gen(length) + '\n') | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment