python hashlib code example
Example 1: python hashlib.sha512()
from hashlib import sha512
print(sha512('hello'.encode()).hexdigest())
Example 2: python hash
from hashlib import blake2b
import time
k = str(time.time()).encode('utf-8')
h = blake2b(key=k, digest_size=16)
h.hexdigest()
Example 3: python file hashlib
import hashlib
BLOCKSIZE = 65536
hasher = hashlib.md5()
with open('anotherfile.txt', 'rb') as afile:
buf = afile.read(BLOCKSIZE)
while len(buf) > 0:
hasher.update(buf)
buf = afile.read(BLOCKSIZE)
print(hasher.hexdigest())