import hmac
import hashlib
import base64
dig = hmac.new(b'1234567890', msg=your_bytes_string, digestmod=hashlib.sha256).digest()
base64.b64encode(dig).decode() # py3k-mode
'Nace+U3Az4OhN7tISqgs1vdLBHBEijWcBeCqL5xN9xg='
# Hash a single string with hashlib.sha256
import hashlib
a_string = 'this string holds important and private information'
hashed_string = hashlib.sha256(a_string.encode('utf-8')).hexdigest()
print(hashed_string)
import hashlib
name = "grepper"
hashed_name = hashlib.sha256(hashed_name.encode('utf-8')).hexdigest())
print(hashed_name)
# result: 82475175ad97f60d1e2c57ef5fd8ae45629d555e1644d6f2a37b69b550a96e95
import hmac
import hashlib
hmac.new(secret.encode(), data_str.encode(), hashlib.sha256).hexdigest()
import hmac
import hashlib
dig = hmac.new(bytes(secret, 'latin-1'), msg=bytes("timestamp=1591702613943",'latin-1' ) , digestmod=hashlib.sha256).hexdigest()