-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGenerate_Password.py
71 lines (54 loc) · 1.92 KB
/
Generate_Password.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
# Generate Password
# Built by Mahdi Rabiee
# Created: Sunday, August 7, 2022
from colorama import Fore
import random
import os
# Clear Screen
os.system("cls")
# Splash Screen
SplashScreen = """
::::
::: G E N E R A T E P A S S W O R D
::
"""
print(Fore.BLUE + SplashScreen)
print("S. Show all saved passwords")
print("C. Clear all saved passwords")
print("D. Clear password file")
print("E. Exit the app \n" + Fore.WHITE)
# Characters
CharacterLower = "abcdefghijklmnoqrstuvwxyz"
CharacterUpper = "ABCDEFGHIJKLMNOQRSTUVWXYZ"
CharacterNumber = "0123456789"
CharacterSymbol = "[]{}()*;/\,_-#@$!%&=+"
Set = CharacterLower + CharacterUpper + CharacterNumber + CharacterSymbol
while True:
Length = input(Fore.BLUE + "Specify the password length (Allowed to 81 characters): " + Fore.WHITE)
if 's' == Length.lower():
try:
file = open("listpasswords.txt", "r")
print(Fore.YELLOW + file.read() + Fore.WHITE)
except:
print(Fore.RED + "The 'listpasswords.txt' file is not found. \n" + Fore.WHITE)
continue
elif 'c' == Length.lower():
file = open("listpasswords.txt", "w")
file.write("")
print(Fore.GREEN + "Cleanup was successfully completed. \n" + Fore.WHITE)
continue
elif 'd' == Length.lower():
try:
file = "listpasswords.txt"
os.remove(file)
print(Fore.GREEN + "The 'listpasswords.txt' file has been successfully deleted. \n" + Fore.WHITE)
except:
print(Fore.RED + "The 'listpasswords.txt' file is not found. \n" + Fore.WHITE)
continue
elif 'e' == Length.lower():
exit()
GeneratePass = "".join(random.sample(Set,int(Length)))
print(GeneratePass , "\n")
with open("listpasswords.txt", "a") as file:
file.write(GeneratePass + "\n\n")
file.close()