Create a new HMAC object. key: bytes or buffer, key for the keyed hash object. 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*
(self, key, msg=None, digestmod='')
| 54 | ) |
| 55 | |
| 56 | def __init__(self, key, msg=None, digestmod=''): |
| 57 | """Create a new HMAC object. |
| 58 | |
| 59 | key: bytes or buffer, key for the keyed hash object. |
| 60 | msg: bytes or buffer, Initial input for the hash or None. |
| 61 | digestmod: A hash name suitable for hashlib.new(). *OR* |
| 62 | A hashlib constructor returning a new hash object. *OR* |
| 63 | A module supporting PEP 247. |
| 64 | |
| 65 | Required as of 3.8, despite its position after the optional |
| 66 | msg argument. Passing it as a keyword argument is |
| 67 | recommended, though not required for legacy API reasons. |
| 68 | """ |
| 69 | |
| 70 | if not isinstance(key, (bytes, bytearray)): |
| 71 | raise TypeError(f"key: expected bytes or bytearray, " |
| 72 | f"but got {type(key).__name__!r}") |
| 73 | |
| 74 | if not digestmod: |
| 75 | raise TypeError("Missing required argument 'digestmod'.") |
| 76 | |
| 77 | self.__init(key, msg, digestmod) |
| 78 | |
| 79 | def __init(self, key, msg, digestmod): |
| 80 | if _hashopenssl and isinstance(digestmod, (str, _functype)): |
nothing calls this directly
no test coverage detected