python--sha256

 

import hmac
import hashlib


def get_hmacsha256(key, message):
key_bytes = bytes(key, 'utf-8')
message_bytes = bytes(message, 'utf-8')
hmacsha256_str = hmac.new(key_bytes, message_bytes, digestmod=hashlib.sha256).hexdigest()
return hmacsha256_str


posted on 2018-02-04 16:29  我要的明天  阅读(842)  评论(0编辑  收藏  举报

导航