-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
44 lines (31 loc) · 1.13 KB
/
Copy pathmain.py
File metadata and controls
44 lines (31 loc) · 1.13 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
import random
import secrets
import string
from colorama import Fore, Style
def choiceChar(Alphabet: str, numberChar):
letters = []
for i in range(numberChar):
letters.append(secrets.choice(Alphabet))
return letters
def passworGenerator(length: int = 5):
print(Fore.YELLOW +
("Este generador crea contraseñas de 12 caracteres de longitud."))
vowels = "aeiou"
numbers = "123456789"
characters = "._-@#!/%&?¡"
password = []
try:
if length >= 4:
password = choiceChar(string.ascii_letters,
length) + choiceChar(vowels, 1) + choiceChar(characters, 3) + choiceChar(numbers, 3)
random.shuffle(password)
password_string = "".join(password)
print(Fore.GREEN +
f"Tu nueva contraseña es: {password_string}".center(60))
else:
print(Fore.BLUE + "Para una contraseña segura deber ser mayor la longitud.")
except Exception as a:
print(Fore.RED + f"Ingresa un número, por favor. {a}")
print(Style.RESET_ALL)
if __name__ == "__main__":
passworGenerator()