-
Notifications
You must be signed in to change notification settings - Fork 1
/
hashlib-sha256.py
32 lines (28 loc) · 1.11 KB
/
hashlib-sha256.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
31
32
import hashlib
'''
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.
'''
def encrypt_string(hash_string):
sha_signature = \
hashlib.sha256(hash_string.encode()).hexdigest()
return sha_signature
entrar = input('Deseja fazer login S/N : ')
if entrar == 'S' or entrar == 's':
# encriptação
hash_string = input('Digite sua Senha: ')
sha_signature = encrypt_string(hash_string)
# saida do valor criptografado
print('--------------------------------------------------------------------------------------------------------')
print(sha_signature[:8])
print('--------------------------------------------------------------------------------------------------------')
ver = input('Deseja visualizar sua senha S/N : ')
if ver == 'S' or ver == 's':
print('--------------------------')
print(f'Sua senha é : {hash_string}')
print('--------------------------')
else:
print('Saindo..')
else:
print('Saindo...')