Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import hashlib
- hash_database = {"185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969": "Pop"} #Хэшированный пароль:Логин
- def check_keys(database, key):
- if key in list(database.keys()):
- return True
- else: return False
- def check_values(database, value):
- if value in list(database.values()):
- return True
- else: return False
- def encrypt_string(string):
- sha_signature = hashlib.sha256(string.encode()).hexdigest()
- return sha_signature
- def decrypt_hash(password, user_input):
- count = 0
- keys = list(hash_database.keys())
- values = list(hash_database.values())
- for x in range(len(hash_database)):
- if values[x] == user_input and keys[x] == encrypt_string(password):
- print("Вход выполнен.")
- break
- else:
- count += 1
- if count == 3:
- print("Логин и пароль не совпадают.")
- break
- def login(username):
- if check_values(hash_database, username):
- user_password_input = input("Введите пароль: ")
- decrypt_hash(user_password_input, username)
- else: print("Логина нет в базе!")
- user_hash_input = input("Введите логин: ")
- login(user_hash_input)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement