-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPassword Generator.py
More file actions
67 lines (45 loc) · 1.67 KB
/
Password Generator.py
File metadata and controls
67 lines (45 loc) · 1.67 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
58
59
60
61
62
63
64
65
66
67
# PASSWORD GENERATOR
print()
import random
import string
print('----Hello User!---- \nTo use our services, create an account first.')
class Account:
def __init__(self, email, password):
self.email = email
self.__password = password
def get_account_info(self):
return f"Your Account is named: {self.email} \nYou can use it for further login."
while True:
login = input("Enter your E-mail Address: ")
if "@" not in login:
print("Invalid email. Please include '@' in your email address.")
continue
print(f"You entered: {login}")
correctness = input("Is the entered E-mail address correct? (Y/N) ").lower()
correctness = correctness.lower()
if correctness == "y":
print("Great!")
print("Generate a strong & unique password for your account.")
break
else:
print("Please enter your E-mail address again.")
def user_approval():
approval = input("Do you want to generate a password? (yes/no): ").strip().lower()
if approval == "yes" or "y" :
return True
return False
if user_approval():
char = string.ascii_letters + string.digits + string.punctuation
pass_len = 12
password = ""
for val in range(pass_len):
print(random.choice(char), end = '')
Acc1 = Account(login, password)
print("\nYou successfully created your account.")
print(Acc1.get_account_info())
else:
user_pass = input("Enter your own password: ")
Acc1 = Account(login, user_pass)
print("\nYou successfully created your account.")
print(Acc1.get_account_info())
print()