from gmssl import sm4, sm3
def sm3_hash(message: str):
"""
国密sm3加密
:param message: 消息值,bytes类型
:return: 哈希值
"""
msg_list = [i for i in bytes(message.encode('UTF-8'))]
hash_hex = sm3.sm3_hash(msg_list)
return hash_hex
# main
if __name__ == '__main__':
print("main begin")
message = "Alibaba"
print(sm3_hash(message))
2b6fe64498e33001e123a320b921b99f5db8909463d790356196e6c878743f95
标签:__,hash,SM3,sm3,国密,message,main,Python3 From: https://www.cnblogs.com/leoshi/p/17270230.html