-
Notifications
You must be signed in to change notification settings - Fork 1
/
generate_password_memory.py
116 lines (87 loc) · 2.72 KB
/
generate_password_memory.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
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
'''
Generate Password Memory is an app to create very strong passwords and
also the storage of all the passwords that is,
it's good because you are no longer worried
about forgetting your passwords.
See Code Github: https://github.com/Mhadi-1382/generate-password-memory
'''
import sqlite3
import random
import string
import colorama
import os
import datetime
connectdb = sqlite3.connect("password_database.db")
cursor = connectdb.cursor()
cursor.execute('''
CREATE TABLE IF NOT EXISTS passwordMemory (
Password TEXT,
CreatedDate DATE
);
''')
def splash_screen():
"""Splash screen"""
os.system("cls")
splash_printer = """
------------------------------------------------
-- G E N E R A T E P A S S W O R D M E M O R Y
------------------------------------------------
__ MADE: MOHAMMAD MAHDI RABIEE __
__ GITHUB: https://github.com/Mhadi-1382/ __
[0] - Generate Password
[1] - Show Generated Passwords
[2] - Delete Generated Passwords
[3] - Exit
Choose Options:
"""
print(colorama.Fore.RED + splash_printer + colorama.Fore.WHITE)
splash_screen()
def prompt():
"""Prompt or get commands"""
prompt_get_user = int(input(":: "))
if prompt_get_user == 0:
generate_password()
elif prompt_get_user == 1:
show_password()
print()
elif prompt_get_user == 2:
delete_password()
elif prompt_get_user == 3:
connectdb.close()
exit()
else:
print(colorama.Fore.YELLOW + "[!] INVALID." + colorama.Fore.WHITE + "\n")
prompt()
def generate_password():
"""Generate password"""
alpha = string.ascii_letters
symbol = string.punctuation
numbers = string.digits
set_char = alpha + symbol + numbers
while True:
len_password = input("LEN PASSWORD: ")
result = "".join(random.sample(set_char, int(len_password)))
print(result + "\n")
result_send_database = (f'{result}', f'{datetime.datetime.now()}',)
cursor.execute('''
INSERT INTO passwordMemory VALUES(?,?);
''', result_send_database)
connectdb.commit()
def delete_password():
"""Delete passwords"""
cursor.execute('''
DROP TABLE passwordMemory;
''')
connectdb.commit()
print(colorama.Fore.GREEN + "[+] PASSWORD HAVE BEEN SUCCESSFULLY DELRTED." + colorama.Fore.WHITE + "\n")
def show_password():
"""Show passwords"""
cursor.execute('''
SELECT * FROM passwordMemory;
''')
show_all_password = cursor.fetchall()
for passwords in show_all_password:
print(passwords)
if show_all_password == []:
print(colorama.Fore.YELLOW + "[-] PASSWORD HAS NOT BEEN SAVED." + colorama.Fore.WHITE)
prompt()