forked from bharat40/SCM-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRandom Password Generator
64 lines (30 loc) · 2.11 KB
/
Random Password Generator
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
58
59
60
61
62
63
import random
def generatepasswords(passwordlength,z):
words = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" # alphanumeric that will be inlcluded in password
if z=="yes" or z=="Yes" or z=="YES" or "YEs" or "yES" or "yeS":
words+="!@#$&?" # symbols that will be inlcuded in the password depending on the user
mainpassword = [] # taking empty list that will be used for storing final generated passwords
for i in passwordlength:
password = ""
for j in range(i):
letterindex = random.randrange(len(words)) # this method will return a randomly selected word
password += words[letterindex]
mainpassword.append(password) # appending this into the empty list that we created earlier
return mainpassword
def maincode():
nopasswords = int(input("PLEASE ENTER THE NUMBER OF PASSWORDS YOU WANT: ")) # take inputs from user
print("...../GENERATING",nopasswords,"PASSWORDS PLEASE FILL UP THE FOLLOWING DETAILS/.....")
q=input("DO YOU WANT SYMBOLS (!@#$&?) IN YOUR PASSWORD? IF (YES) THEN ENTER YES OTHERWISE ENTER ANY CHARACTER: ")
passwordlen = []
print("(PLEASE NOTE) THE LENGTH OF THE PASSWORD SHOULD BE GREATER THAN 4.")
for i in range(nopasswords):
length=int(input("ENTER THE LENGTH OF YOUR PASSWORD: "))
if length <= 4: # loop for taking input until the user enter the length of passwords more than 4
while length <= 4:
length=int(input("ERROR! PLEASE ENTER LENGTH GREATER THAN 4: "))
passwordlen.append(length)
password = generatepasswords(passwordlen,q)
for i in range(len(password)): # loop for printing the number of passwords decided by the user
print("PASSWORD",i+1,"=",password[i]) # printing the generated passwords
maincode()
#done