-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPasswordGen.py
More file actions
57 lines (41 loc) · 1.76 KB
/
PasswordGen.py
File metadata and controls
57 lines (41 loc) · 1.76 KB
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
53
54
55
56
57
#Hardik Shahu
#Password Generator
import random
#List of pos chars we can use to make our passwords (Feel free to edit this string to match your needs!)
possChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()-=+/?:"
#welcome messsage for the user
start = input("Welcome to password generator!\nPress any key to begin! ")
#So they only enter positive number
while(True == True):
numberOfPass = int(input("Please enter the number of passwords you'd like: "))
if(numberOfPass <= 0 ):
print("Error, you entered a negative value, please try again with only positives! ")
else:
break
#Checks that they enter higher value for the upper bound
while(True == True):
#So they only enter positive number
while(True == True):
lengthLower = int(input("Please enter the minimum length of each password: "))
if(lengthLower <= 0 ):
print("Error, you entered an invalid value, please try again with only positives! ")
else:
break
#So they only enter positive number
while(True == True):
lengthUpper = int(input("Please enter the maximum length of each password: "))
if(lengthUpper <= 0 ):
print("Error, you entered an invalid value, please try again with only positives! ")
else:
break
if(lengthUpper < lengthLower):
print("Error, you entered higher value for lower bound than upperbound ")
else:
break
print("Your passwords are: ")
for i in range(numberOfPass):
password = ""
length = random.randint(lengthLower, lengthUpper)
for j in range(length):
password += random.choice(possChars)
print(password)