python3 sha256 pure code example
Example 1: python sha256 of file
import hashlib
filename = input("Enter the input file name: ")
sha256_hash = hashlib.sha256()
with open(filename,"rb") as f:
for byte_block in iter(lambda: f.read(4096),b""):
sha256_hash.update(byte_block)
print(sha256_hash.hexdigest())
Example 2: python hmac sha256
import hmac
import hashlib
nonce = 1234
customer_id = 123232
api_key = 2342342348273482374343434
API_SECRET = 892374928347928347283473
message = '{} {} {}'.format(nonce, customer_id, api_key)
signature = hmac.new(
str(API_SECRET),
msg=message,
digestmod=hashlib.sha256
).hexdigest().upper()
print signature