-
hmac
This module implements the HMAC algorithm as described by RFC 2104.
-
functions
hmac.new(key, msg=None, digestmod='') hmac.digest(key, meg, digest)
-
mothods from HMAC object
HMAC.update(msg) # m.update(a);m.update(b) is equivalent to m.update(a+b) HMAC.digest() HMAC.hexdigest() HMAC.copy() HMAC.digest_size HMAC.block_size HMAC.compare_digest(a,b)
-
Usage Example
import hmac message = b'Hello, world!' key = b'secret' h = hmac.new(key, message, digestmod='MD5') # 如果消息很长,可以多次调用h.update(msg) h.hexdigest()
-
References
理解hmac module in Python
最新推荐文章于 2023-03-08 08:41:43 发布