Created
March 30, 2017 18:29
-
-
Save carterprince/26cd01db2aa8fdb08b150c75040b68cb to your computer and use it in GitHub Desktop.
Generates a random password using common ascii numbers, letters and symbols.
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 math | |
import random | |
#get user input as to how long they want the password | |
passwordlen = int(input("How long would you like your password to be? : ")) | |
#our chars | |
chars = "abcdefghijklmnopqrstuvwxyz1234567890!@#$%^&*" | |
charlist = [] | |
#couldn't figure out the split() function so I just did it with a for loop | |
for x in chars: | |
charlist.append(x) | |
#define password list; we can splice this back together once we are done appending | |
password = [] | |
for x in range(0, passwordlen): | |
#this picks a random character from the charlist | |
ch = math.floor(random.randint(0, len(chars))) | |
#append the chosen character | |
password.append(charlist[ch]) | |
#join the password list | |
print(''.join(password)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment