Password Generator
Password Generator by Fosbaunknown
python
a year ago
4.6 kB
15
No Index
import time
import os
import secrets
import string
import random
CARATTERI = string.ascii_letters
NUMERI = string.digits
welcome = ('''
██████╗░░█████╗░░██████╗░██████╗░██╗░░░░░░░██╗░█████╗░██████╗░██████╗░
██╔══██╗██╔══██╗██╔════╝██╔════╝░██║░░██╗░░██║██╔══██╗██╔══██╗██╔══██╗
██████╔╝███████║╚█████╗░╚█████╗░░╚██╗████╗██╔╝██║░░██║██████╔╝██║░░██║
██╔═══╝░██╔══██║░╚═══██╗░╚═══██╗░░████╔═████║░██║░░██║██╔══██╗██║░░██║
██║░░░░░██║░░██║██████╔╝██████╔╝░░╚██╔╝░╚██╔╝░╚█████╔╝██║░░██║██████╔╝
╚═╝░░░░░╚═╝░░╚═╝╚═════╝░╚═════╝░░░░╚═╝░░░╚═╝░░░╚════╝░╚═╝░░╚═╝╚═════╝░
░██████╗░███████╗███╗░░██╗███████╗██████╗░░█████╗░████████╗░█████╗░██████╗░
██╔════╝░██╔════╝████╗░██║██╔════╝██╔══██╗██╔══██╗╚══██╔══╝██╔══██╗██╔══██╗
██║░░██╗░█████╗░░██╔██╗██║█████╗░░██████╔╝███████║░░░██║░░░██║░░██║██████╔╝
██║░░╚██╗██╔══╝░░██║╚████║██╔══╝░░██╔══██╗██╔══██║░░░██║░░░██║░░██║██╔══██╗
╚██████╔╝███████╗██║░╚███║███████╗██║░░██║██║░░██║░░░██║░░░╚█████╔╝██║░░██║
░╚═════╝░╚══════╝╚═╝░░╚══╝╚══════╝╚═╝░░╚═╝╚═╝░░╚═╝░░░╚═╝░░░░╚════╝░╚═╝░░╚═╝
--------------------------------------------------------''')
print(welcome)
time.sleep(3)
os.system('cls')
def main():
while True:
lunghezza_password = (input("indicare la lunghezza password: "))
if lunghezza_password == 0 or not lunghezza_password.isdecimal():
print("errore nell'inserimento dei dati...")
continue
else:
lunghezza_password = int(lunghezza_password)
break
while True:
numbers = int(
input(f"Indicare quanti numeri deve avere la password (lunghezza massima = {lunghezza_password}): ")
)
lunghezza_massima_rimanente = lunghezza_password - numbers
quanti_lettere = int(
input(f"indicare quante lettere deve avere la password (lunghezza massima = {lunghezza_massima_rimanente}): ")
)
if lunghezza_password != quanti_lettere + numbers:
print("Errore")
print("La lunghezza della password deve deve coincidere con numeri e lettere da inserire")
os.system('cls')
elif numbers == lunghezza_password or quanti_lettere == lunghezza_password:
time.sleep(1)
print("Errore nell'inserimento dei dati")
elif lunghezza_password == quanti_lettere + numbers:
break
password = ''.join(secrets.choice(CARATTERI) for _ in range(quanti_lettere)) # genera lettere
password += ''.join(secrets.choice(NUMERI) for _ in range(numbers)) # aggiunge numeri
password = ''.join(random.sample(password, len(password))) # mescola la password
for i in range(1, 4):
time.sleep(1)
os.system('cls')
print("Generando la password" + '.' * i)
print("La password generata è:", password)
main()Editor is loading...