-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpassword_v2.py
More file actions
40 lines (35 loc) · 1.47 KB
/
password_v2.py
File metadata and controls
40 lines (35 loc) · 1.47 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
import locale
import string
import secrets
import random
import re
def check_password(password):
password_pattern = "(?=.*[a-z])(?=.*[A-Z])(?=.*[\.,-_+\*@$#%&])[A-Za-z\d@$@$#%&\.,-_+\*]{8,}$"
return re.fullmatch(password_pattern, password) != None
""" def check_password(password):
password_pattern = "(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&/_=;:<>|#,\*\'\"\-\+\[\]])[A-Za-z\d@$!%*?&/_=;:<>|#,\*\'\"\-\+\[\]]{8,}$"
return re.fullmatch(password_pattern, password) != None """
locale.setlocale(locale.LC_ALL,'')
pass_characters = string.ascii_lowercase +\
string.ascii_uppercase +\
string.digits +\
string.punctuation
while True:
try:
cantidad=int(input("ingrese la cantidad de Passwords a generar"))
except ValueError:
print(f"El valor ingresado es invalido. debe ingresar un numero entero")
else:
break
min_t=int(input("Ingrese valor mínimo: "))
max_t=int(input("Ingrese valor mínimo: "))
print(f"Generando... {locale.format_string('%2d',cantidad,grouping=True)} password")
for i in range(1,cantidad):
password=''.join(secrets.choice(pass_characters) for i in range(0,random.randint(min_t,max_t)))
try:
with open('random_password.txt', 'a') as pass_file:
pass_file.write(password+'\n')
except PermissionError as error:
print('Falla de acceso al archivo random_password.txt, verifique que este cerrado')
print(f"Error: {error} ")
exit()