forked from kishanrajput23/Awesome-Python-Projects
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPasswordgen.py
31 lines (22 loc) · 817 Bytes
/
Passwordgen.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
import string
import random
print("Welcone to Password Generator\n")
forwhat = input("Enter the website or application for which you want to generate password:\n")
length = int(input("Enter the length of password(Max-94)\n"))
if length >= 94:
print("Max length crossed.")
quit()
s1 = list(string.ascii_lowercase)
s2 = list(string.ascii_uppercase)
s3 = list(string.digits)
s4 = list(string.punctuation)
elements = s1+s2+s3+s4
random.shuffle(elements)
password = "".join(elements[0:length])
print("The safe generated password is :",password,"\n")
saveyn = input("Do you want save the password?\nEnter Yes or No\n")
if saveyn == "Yes":
f = open("generatedpasswords.txt","a")
f.write(forwhat + " - " + password+"\n")
f.close()
print("Your password is succesfully saved in 'generatedpasswords.txt' file.")