Created
September 7, 2016 05:05
-
-
Save jampola/e22506d03a9b2cf26594675008c75745 to your computer and use it in GitHub Desktop.
Generate a random password based user selected length. (upper,lower letters, numbers and symbols)
This file contains hidden or 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 randint | |
def main(passlen = 8): | |
password = [] | |
for x in range(0,passlen): | |
r = randint(1, 4) | |
if r == 1: | |
password.append(chr(randint(97,122))) | |
elif r == 2: | |
password.append(str(randint(0,9))) | |
elif r == 3: | |
password.append(chr(randint(33,47))) | |
else: | |
password.append(chr(randint(65,90))) | |
return("".join(password)) | |
print(main(16)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment