💾 Archived View for tris.fyi › pydoc › hmac captured on 2023-04-26 at 13:29:52. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-01-29)

-=-=-=-=-=-=-

Back to module index

Go to module by name

hmac

HMAC (Keyed-Hashing for Message Authentication) module.

Implements the HMAC algorithm as described by RFC 2104.

Classes

HMAC

RFC 2104 HMAC class.  Also complies with RFC 4231.

    This supports the API for Cryptographic Hash Functions (PEP 247).
    
copy(self)

  Return a separate copy of this hashing object.

          An update to this copy won't affect the original object.
        
digest(self)

  Return the hash value of this hashing object.

          This returns the hmac value as bytes.  The object is
          not altered in any way by this function; you can continue
          updating the object after calling this function.
        
hexdigest(self)

  Like digest(), but returns a string of hexadecimal digits instead.
        
update(self, msg)

  Feed data from msg into this hashing object.
block_size = <member 'block_size' of 'HMAC' objects>
blocksize = 64
digest_size = <member 'digest_size' of 'HMAC' objects>
name = <property object at 0x7f75e2e3d6c0>

Functions

compare_digest

compare_digest(a, b, /)

  Return 'a == b'.

  This function uses an approach designed to prevent
  timing analysis, making it appropriate for cryptography.

  a and b must both be of the same type: either str (ASCII only),
  or any bytes-like object.

  Note: If a and b are of different lengths, or if an error occurs,
  a timing attack could theoretically reveal information about the
  types and lengths of a and b--but not their values.

digest

digest(key, msg, digest)

  Fast inline implementation of HMAC.

      key: bytes or buffer, The key for the keyed hash object.
      msg: bytes or buffer, Input message.
      digest: A hash name suitable for hashlib.new() for best performance. *OR*
              A hashlib constructor returning a new hash object. *OR*
              A module supporting PEP 247.
    

new

new(key, msg=None, digestmod='')

  Create a new hashing object and return it.

      key: bytes or buffer, The starting key for the hash.
      msg: bytes or buffer, Initial input for the hash, or None.
      digestmod: A hash name suitable for hashlib.new(). *OR*
                 A hashlib constructor returning a new hash object. *OR*
                 A module supporting PEP 247.

                 Required as of 3.8, despite its position after the optional
                 msg argument.  Passing it as a keyword argument is
                 recommended, though not required for legacy API reasons.

      You can now feed arbitrary bytes into the object using its update()
      method, and can ask for the hash value at any time by calling its digest()
      or hexdigest() methods.
    

Other members

digest_size = None
trans_36 = b'67452301>?<=:;89&\'$%"# !./,-*+()\x16\x17\x14\x15\x12\x13\x10\x11\x1e\x1f\x1c\x1d\x1a\x1b\x18\x19\x06\x07\x04\x05\x02\x03\x00\x01\x0e\x0f\x0c\r\n\x0b\x08\tvwturspq~\x7f|}z{xyfgdebc`anolmjkhiVWTURSPQ^_\\]Z[XYFGDEBC@ANOLMJKHI\xb6\xb7\xb4\xb5\xb2\xb3\xb0\xb1\xbe\xbf\xbc\xbd\xba\xbb\xb8\xb9\xa6\xa7\xa4\xa5\xa2\xa3\xa0\xa1\xae\xaf\xac\xad\xaa\xab\xa8\xa9\x96\x97\x94\x95\x92\x93\x90\x91\x9e\x9f\x9c\x9d\x9a\x9b\x98\x99\x86\x87\x84\x85\x82\x83\x80\x81\x8e\x8f\x8c\x8d\x8a\x8b\x88\x89\xf6\xf7\xf4\xf5\xf2\xf3\xf0\xf1\xfe\xff\xfc\xfd\xfa\xfb\xf8\xf9\xe6\xe7\xe4\xe5\xe2\xe3\xe0\xe1\xee\xef\xec\xed\xea\xeb\xe8\xe9\xd6\xd7\xd4\xd5\xd2\xd3\xd0\xd1\xde\xdf\xdc\xdd\xda\xdb\xd8\xd9\xc6\xc7\xc4\xc5\xc2\xc3\xc0\xc1\xce\xcf\xcc\xcd\xca\xcb\xc8\xc9'
trans_5C = b'\\]^_XYZ[TUVWPQRSLMNOHIJKDEFG@ABC|}~\x7fxyz{tuvwpqrslmnohijkdefg`abc\x1c\x1d\x1e\x1f\x18\x19\x1a\x1b\x14\x15\x16\x17\x10\x11\x12\x13\x0c\r\x0e\x0f\x08\t\n\x0b\x04\x05\x06\x07\x00\x01\x02\x03<=>?89:;45670123,-./()*+$%&\' !"#\xdc\xdd\xde\xdf\xd8\xd9\xda\xdb\xd4\xd5\xd6\xd7\xd0\xd1\xd2\xd3\xcc\xcd\xce\xcf\xc8\xc9\xca\xcb\xc4\xc5\xc6\xc7\xc0\xc1\xc2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