2
2
3
3
import sys
4
4
from typing import AbstractSet , Optional , Union
5
-
6
- _DataType = Union [bytes , bytearray , memoryview ]
5
+ from _typeshed import ReadableBuffer
7
6
8
7
class _Hash (object ):
9
8
digest_size : int
@@ -14,54 +13,54 @@ class _Hash(object):
14
13
# formally specified, so may not exist on some platforms
15
14
name : str
16
15
17
- def __init__ (self , data : _DataType = ...) -> None : ...
16
+ def __init__ (self , data : ReadableBuffer = ...) -> None : ...
18
17
19
18
def copy (self ) -> _Hash : ...
20
19
def digest (self ) -> bytes : ...
21
20
def hexdigest (self ) -> str : ...
22
- def update (self , __data : _DataType ) -> None : ...
21
+ def update (self , __data : ReadableBuffer ) -> None : ...
23
22
24
23
if sys .version_info >= (3 , 9 ):
25
- def md5 (string : _DataType = ..., * , usedforsecurity : bool = ...) -> _Hash : ...
26
- def sha1 (string : _DataType = ..., * , usedforsecurity : bool = ...) -> _Hash : ...
27
- def sha224 (string : _DataType = ..., * , usedforsecurity : bool = ...) -> _Hash : ...
28
- def sha256 (string : _DataType = ..., * , usedforsecurity : bool = ...) -> _Hash : ...
29
- def sha384 (string : _DataType = ..., * , usedforsecurity : bool = ...) -> _Hash : ...
30
- def sha512 (string : _DataType = ..., * , usedforsecurity : bool = ...) -> _Hash : ...
24
+ def md5 (string : ReadableBuffer = ..., * , usedforsecurity : bool = ...) -> _Hash : ...
25
+ def sha1 (string : ReadableBuffer = ..., * , usedforsecurity : bool = ...) -> _Hash : ...
26
+ def sha224 (string : ReadableBuffer = ..., * , usedforsecurity : bool = ...) -> _Hash : ...
27
+ def sha256 (string : ReadableBuffer = ..., * , usedforsecurity : bool = ...) -> _Hash : ...
28
+ def sha384 (string : ReadableBuffer = ..., * , usedforsecurity : bool = ...) -> _Hash : ...
29
+ def sha512 (string : ReadableBuffer = ..., * , usedforsecurity : bool = ...) -> _Hash : ...
31
30
elif sys .version_info >= (3 , 8 ):
32
- def md5 (string : _DataType = ...) -> _Hash : ...
33
- def sha1 (string : _DataType = ...) -> _Hash : ...
34
- def sha224 (string : _DataType = ...) -> _Hash : ...
35
- def sha256 (string : _DataType = ...) -> _Hash : ...
36
- def sha384 (string : _DataType = ...) -> _Hash : ...
37
- def sha512 (string : _DataType = ...) -> _Hash : ...
31
+ def md5 (string : ReadableBuffer = ...) -> _Hash : ...
32
+ def sha1 (string : ReadableBuffer = ...) -> _Hash : ...
33
+ def sha224 (string : ReadableBuffer = ...) -> _Hash : ...
34
+ def sha256 (string : ReadableBuffer = ...) -> _Hash : ...
35
+ def sha384 (string : ReadableBuffer = ...) -> _Hash : ...
36
+ def sha512 (string : ReadableBuffer = ...) -> _Hash : ...
38
37
else :
39
- def md5 (__string : _DataType = ...) -> _Hash : ...
40
- def sha1 (__string : _DataType = ...) -> _Hash : ...
41
- def sha224 (__string : _DataType = ...) -> _Hash : ...
42
- def sha256 (__string : _DataType = ...) -> _Hash : ...
43
- def sha384 (__string : _DataType = ...) -> _Hash : ...
44
- def sha512 (__string : _DataType = ...) -> _Hash : ...
38
+ def md5 (__string : ReadableBuffer = ...) -> _Hash : ...
39
+ def sha1 (__string : ReadableBuffer = ...) -> _Hash : ...
40
+ def sha224 (__string : ReadableBuffer = ...) -> _Hash : ...
41
+ def sha256 (__string : ReadableBuffer = ...) -> _Hash : ...
42
+ def sha384 (__string : ReadableBuffer = ...) -> _Hash : ...
43
+ def sha512 (__string : ReadableBuffer = ...) -> _Hash : ...
45
44
46
- def new (name : str , data : _DataType = ...) -> _Hash : ...
45
+ def new (name : str , data : ReadableBuffer = ...) -> _Hash : ...
47
46
48
47
algorithms_guaranteed : AbstractSet [str ]
49
48
algorithms_available : AbstractSet [str ]
50
49
51
- def pbkdf2_hmac (hash_name : str , password : _DataType , salt : _DataType , iterations : int , dklen : Optional [int ] = ...) -> bytes : ...
50
+ def pbkdf2_hmac (hash_name : str , password : ReadableBuffer , salt : ReadableBuffer , iterations : int , dklen : Optional [int ] = ...) -> bytes : ...
52
51
53
52
if sys .version_info >= (3 , 6 ):
54
53
class _VarLenHash (object ):
55
54
digest_size : int
56
55
block_size : int
57
56
name : str
58
57
59
- def __init__ (self , data : _DataType = ...) -> None : ...
58
+ def __init__ (self , data : ReadableBuffer = ...) -> None : ...
60
59
61
60
def copy (self ) -> _VarLenHash : ...
62
61
def digest (self , __length : int ) -> bytes : ...
63
62
def hexdigest (self , __length : int ) -> str : ...
64
- def update (self , __data : _DataType ) -> None : ...
63
+ def update (self , __data : ReadableBuffer ) -> None : ...
65
64
66
65
sha3_224 = _Hash
67
66
sha3_256 = _Hash
@@ -70,7 +69,7 @@ if sys.version_info >= (3, 6):
70
69
shake_128 = _VarLenHash
71
70
shake_256 = _VarLenHash
72
71
73
- def scrypt (password : _DataType , * , salt : Optional [_DataType ] = ..., n : Optional [int ] = ..., r : Optional [int ] = ..., p : Optional [int ] = ..., maxmem : int = ..., dklen : int = ...) -> bytes : ...
72
+ def scrypt (password : ReadableBuffer , * , salt : Optional [ReadableBuffer ] = ..., n : Optional [int ] = ..., r : Optional [int ] = ..., p : Optional [int ] = ..., maxmem : int = ..., dklen : int = ...) -> bytes : ...
74
73
75
74
class _BlakeHash (_Hash ):
76
75
MAX_DIGEST_SIZE : int
@@ -79,9 +78,9 @@ if sys.version_info >= (3, 6):
79
78
SALT_SIZE : int
80
79
81
80
if sys .version_info >= (3 , 9 ):
82
- def __init__ (self , __data : _DataType = ..., * , digest_size : int = ..., key : _DataType = ..., salt : _DataType = ..., person : _DataType = ..., fanout : int = ..., depth : int = ..., leaf_size : int = ..., node_offset : int = ..., node_depth : int = ..., inner_size : int = ..., last_node : bool = ..., usedforsecurity : bool = ...) -> None : ...
81
+ def __init__ (self , __data : ReadableBuffer = ..., * , digest_size : int = ..., key : ReadableBuffer = ..., salt : ReadableBuffer = ..., person : ReadableBuffer = ..., fanout : int = ..., depth : int = ..., leaf_size : int = ..., node_offset : int = ..., node_depth : int = ..., inner_size : int = ..., last_node : bool = ..., usedforsecurity : bool = ...) -> None : ...
83
82
else :
84
- def __init__ (self , __data : _DataType = ..., * , digest_size : int = ..., key : _DataType = ..., salt : _DataType = ..., person : _DataType = ..., fanout : int = ..., depth : int = ..., leaf_size : int = ..., node_offset : int = ..., node_depth : int = ..., inner_size : int = ..., last_node : bool = ...) -> None : ...
83
+ def __init__ (self , __data : ReadableBuffer = ..., * , digest_size : int = ..., key : ReadableBuffer = ..., salt : ReadableBuffer = ..., person : ReadableBuffer = ..., fanout : int = ..., depth : int = ..., leaf_size : int = ..., node_offset : int = ..., node_depth : int = ..., inner_size : int = ..., last_node : bool = ...) -> None : ...
85
84
86
85
blake2b = _BlakeHash
87
86
blake2s = _BlakeHash
0 commit comments