| 1 |
import sys |
| 2 |
from _blake2 import blake2b as blake2b, blake2s as blake2s |
| 3 |
from _hashlib import ( |
| 4 |
HASH, |
| 5 |
_HashObject, |
| 6 |
openssl_md5 as md5, |
| 7 |
openssl_sha1 as sha1, |
| 8 |
openssl_sha3_224 as sha3_224, |
| 9 |
openssl_sha3_256 as sha3_256, |
| 10 |
openssl_sha3_384 as sha3_384, |
| 11 |
openssl_sha3_512 as sha3_512, |
| 12 |
openssl_sha224 as sha224, |
| 13 |
openssl_sha256 as sha256, |
| 14 |
openssl_sha384 as sha384, |
| 15 |
openssl_sha512 as sha512, |
| 16 |
openssl_shake_128 as shake_128, |
| 17 |
openssl_shake_256 as shake_256, |
| 18 |
pbkdf2_hmac as pbkdf2_hmac, |
| 19 |
scrypt as scrypt, |
| 20 |
) |
| 21 |
from _typeshed import ReadableBuffer |
| 22 |
from collections.abc import Callable, Set as AbstractSet |
| 23 |
from typing import Protocol, type_check_only |
| 24 |
|
| 25 |
if sys.version_info >= (3, 11): |
| 26 |
__all__ = ( |
| 27 |
"md5", |
| 28 |
"sha1", |
| 29 |
"sha224", |
| 30 |
"sha256", |
| 31 |
"sha384", |
| 32 |
"sha512", |
| 33 |
"blake2b", |
| 34 |
"blake2s", |
| 35 |
"sha3_224", |
| 36 |
"sha3_256", |
| 37 |
"sha3_384", |
| 38 |
"sha3_512", |
| 39 |
"shake_128", |
| 40 |
"shake_256", |
| 41 |
"new", |
| 42 |
"algorithms_guaranteed", |
| 43 |
"algorithms_available", |
| 44 |
"pbkdf2_hmac", |
| 45 |
"file_digest", |
| 46 |
) |
| 47 |
else: |
| 48 |
__all__ = ( |
| 49 |
"md5", |
| 50 |
"sha1", |
| 51 |
"sha224", |
| 52 |
"sha256", |
| 53 |
"sha384", |
| 54 |
"sha512", |
| 55 |
"blake2b", |
| 56 |
"blake2s", |
| 57 |
"sha3_224", |
| 58 |
"sha3_256", |
| 59 |
"sha3_384", |
| 60 |
"sha3_512", |
| 61 |
"shake_128", |
| 62 |
"shake_256", |
| 63 |
"new", |
| 64 |
"algorithms_guaranteed", |
| 65 |
"algorithms_available", |
| 66 |
"pbkdf2_hmac", |
| 67 |
) |
| 68 |
|
| 69 |
def new(name: str, data: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> HASH: ... |
| 70 |
|
| 71 |
algorithms_guaranteed: AbstractSet[str] |
| 72 |
algorithms_available: AbstractSet[str] |
| 73 |
|
| 74 |
if sys.version_info >= (3, 11): |
| 75 |
@type_check_only |
| 76 |
class _BytesIOLike(Protocol): |
| 77 |
def getbuffer(self) -> ReadableBuffer: ... |
| 78 |
|
| 79 |
@type_check_only |
| 80 |
class _FileDigestFileObj(Protocol): |
| 81 |
def readinto(self, buf: bytearray, /) -> int: ... |
| 82 |
def readable(self) -> bool: ... |
| 83 |
|
| 84 |
def file_digest( |
| 85 |
fileobj: _BytesIOLike | _FileDigestFileObj, digest: str | Callable[[], _HashObject], /, *, _bufsize: int = 262144 |
| 86 |
) -> HASH: ... |
| 87 |
|
| 88 |
|
| 89 |
_Hash = HASH |