-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrandom_password_gen.py
52 lines (36 loc) · 1.47 KB
/
random_password_gen.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import random
chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()-=_+`~[]{]\|;:,<.>/?'
exitMessage = 0
passwordGeneratorUsage = 1
passwordGeneratorPrompt = 1
while exitMessage != 1:
while passwordGeneratorUsage == 1:
passwordGeneratorPrompt = 1
passwordNum = input('How many passwords would you like to generate?: ')
passwordNum = int(passwordNum)
passwordLength = input('How long will the password(s) be?: ')
passwordLength = int(passwordLength)
print('\n')
print('Here are your password(s): \n')
passwordFile = open('Passwords.txt', 'w')
for p in range(passwordNum):
password = ''
for c in range(passwordLength):
password += random.choice(chars)
print(password)
passwordFile.write(password + '\n')
passwordFile.close()
print('\n')
while passwordGeneratorPrompt == 1:
getContinue = input('Do you want to use the Password Generator again? (Y/N):')
print('\n')
if getContinue == "Y" or getContinue == "y":
passwordGeneratorPrompt = 0
print('\n')
elif getContinue == "N" or getContinue == "n":
exitMessage = 1
passwordGeneratorUsage = 0
passwordGeneratorPrompt = 0
else:
print("Please enter 'Y' or 'N :'\n")
print('\n')