理解hmac module in Python
发布日期:2021-05-07 14:23:38 浏览次数:12 分类:原创文章

本文共 529 字,大约阅读时间需要 1 分钟。

  • This module implements the HMAC algorithm as described by .

  • 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_sizeHMAC.block_sizeHMAC.compare_digest(a,b)
  • Usage Example

    import hmacmessage = b'Hello, world!'key = b'secret'h = hmac.new(key, message, digestmod='MD5') # 如果消息很长,可以多次调用h.update(msg)h.hexdigest()
  • References

  1. — Secure hashes and message digests
上一篇:理解SPA||Apache license version2.0||petabytes
下一篇:理解Elasticsearch||从docs入手

发表评论

最新留言

能坚持,总会有不一样的收获!
[***.219.124.196]2025年03月31日 19时13分25秒