8 lines
294 B
Python
8 lines
294 B
Python
|
import cryptography.hazmat.primitives.hashes
|
||
|
|
||
|
def get_hash(data):
|
||
|
if isinstance(data, str):
|
||
|
data = data.encode('utf-8')
|
||
|
digest = cryptography.hazmat.primitives.hashes.Hash(cryptography.hazmat.primitives.hashes.SHA256())
|
||
|
digest.update(data)
|
||
|
return digest.finalize().hex()
|