-
Notifications
You must be signed in to change notification settings - Fork 1
/
hashlib-os-sha512.py
30 lines (28 loc) · 1.08 KB
/
hashlib-os-sha512.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
import hashlib
import os
'''
encode() : Converts the string into bytes to be acceptable by hash function.
digest() : Returns the encoded data in byte format.
hexdigest() : Returns the encoded data in hexadecimal format.
'''
entrar = input('Deseja fazer login S/N : ')
if entrar == 'S' or entrar == 's':
user = input('Digite sua senha :')
password_salt = os.urandom(32).hex()
password = user
hash = hashlib.sha512()
hash.update(('%s%s' % (password_salt, password)).encode('utf-8'))
password_hash = hash.hexdigest()
senha = password_hash
print('--------------------------------------------------------------------------------------------------------')
print(senha[:8])
print('--------------------------------------------------------------------------------------------------------')
ver = input('Deseja visualizar sua senha S/N : ')
if ver == 'S' or ver == 's':
print('--------------------------')
print(f'Sua senha e : {user}')
print('--------------------------')
else:
print('Saindo ...')
else:
print('Saindo ...')