Files
typeshed/stdlib/hmac.pyi
T
Pierre Chapuis b0c6fffe28 Introduce the _HashObject protocol (#13553)
This protocol corresponds to what is called "hash object" in the hashlib documentation. In particular, it includes the non-OpenSSL BLAKE2 implementations which do not inherit HASH.
2025-02-27 15:31:56 +01:00

43 lines
1.4 KiB
Python

import sys
from _hashlib import _HashObject
from _typeshed import ReadableBuffer, SizedBuffer
from collections.abc import Callable
from types import ModuleType
from typing import AnyStr, overload
from typing_extensions import TypeAlias
_DigestMod: TypeAlias = str | Callable[[], _HashObject] | ModuleType
trans_5C: bytes
trans_36: bytes
digest_size: None
# In reality digestmod has a default value, but the function always throws an error
# if the argument is not given, so we pretend it is a required argument.
@overload
def new(key: bytes | bytearray, msg: ReadableBuffer | None, digestmod: _DigestMod) -> HMAC: ...
@overload
def new(key: bytes | bytearray, *, digestmod: _DigestMod) -> HMAC: ...
class HMAC:
digest_size: int
block_size: int
@property
def name(self) -> str: ...
def __init__(self, key: bytes | bytearray, msg: ReadableBuffer | None = None, digestmod: _DigestMod = "") -> None: ...
def update(self, msg: ReadableBuffer) -> None: ...
def digest(self) -> bytes: ...
def hexdigest(self) -> str: ...
def copy(self) -> HMAC: ...
def digest(key: SizedBuffer, msg: ReadableBuffer, digest: _DigestMod) -> bytes: ...
if sys.version_info >= (3, 9):
from _hashlib import compare_digest as compare_digest
else:
@overload
def compare_digest(a: ReadableBuffer, b: ReadableBuffer, /) -> bool: ...
@overload
def compare_digest(a: AnyStr, b: AnyStr, /) -> bool: ...