Skip to content

Commit d0dfb3a

Browse files
Create PasswordGenerator.py
1 parent 3d3db17 commit d0dfb3a

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

PasswordGenerator.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import string
2+
import random
3+
4+
print("Welcone to Password Generator\n")
5+
6+
forwhat = input("Enter the website or application for which you want to generate password:\n")
7+
length = int(input("Enter the length of password(Max-94)\n"))
8+
if length >= 94:
9+
print("Max length crossed.")
10+
quit()
11+
12+
s1 = list(string.ascii_lowercase)
13+
s2 = list(string.ascii_uppercase)
14+
s3 = list(string.digits)
15+
s4 = list(string.punctuation)
16+
17+
elements = s1+s2+s3+s4
18+
19+
random.shuffle(elements)
20+
21+
password = "".join(elements[0:length])
22+
23+
print("The safe generated password is :",password,"\n")
24+
25+
saveyn = input("Do you want save the password?\nEnter Yes or No\n")
26+
27+
if saveyn == "Yes":
28+
f = open("generatedpasswords.txt","a")
29+
f.write(forwhat + " - " + password+"\n")
30+
f.close()
31+
print("Your password is succesfully saved in 'generatedpasswords.txt' file.")

0 commit comments

Comments
 (0)