Format: application/octet-stream
⬇ Download File (4.1 KB)
   1  import sys
   2  from _typeshed import ReadableBuffer
   3  from typing import AbstractSet, Optional
   4  
   5  class _Hash(object):
   6      digest_size: int
   7      block_size: int
   8  
   9      # [Python documentation note] Changed in version 3.4: The name attribute has
  10      # been present in CPython since its inception, but until Python 3.4 was not
  11      # formally specified, so may not exist on some platforms
  12      name: str
  13      def __init__(self, data: ReadableBuffer = ...) -> None: ...
  14      def copy(self) -> _Hash: ...
  15      def digest(self) -> bytes: ...
  16      def hexdigest(self) -> str: ...
  17      def update(self, __data: ReadableBuffer) -> None: ...
  18  
  19  if sys.version_info >= (3, 9):
  20      def md5(string: ReadableBuffer = ..., *, usedforsecurity: bool = ...) -> _Hash: ...
  21      def sha1(string: ReadableBuffer = ..., *, usedforsecurity: bool = ...) -> _Hash: ...
  22      def sha224(string: ReadableBuffer = ..., *, usedforsecurity: bool = ...) -> _Hash: ...
  23      def sha256(string: ReadableBuffer = ..., *, usedforsecurity: bool = ...) -> _Hash: ...
  24      def sha384(string: ReadableBuffer = ..., *, usedforsecurity: bool = ...) -> _Hash: ...
  25      def sha512(string: ReadableBuffer = ..., *, usedforsecurity: bool = ...) -> _Hash: ...
  26  
  27  elif sys.version_info >= (3, 8):
  28      def md5(string: ReadableBuffer = ...) -> _Hash: ...
  29      def sha1(string: ReadableBuffer = ...) -> _Hash: ...
  30      def sha224(string: ReadableBuffer = ...) -> _Hash: ...
  31      def sha256(string: ReadableBuffer = ...) -> _Hash: ...
  32      def sha384(string: ReadableBuffer = ...) -> _Hash: ...
  33      def sha512(string: ReadableBuffer = ...) -> _Hash: ...
  34  
  35  else:
  36      def md5(__string: ReadableBuffer = ...) -> _Hash: ...
  37      def sha1(__string: ReadableBuffer = ...) -> _Hash: ...
  38      def sha224(__string: ReadableBuffer = ...) -> _Hash: ...
  39      def sha256(__string: ReadableBuffer = ...) -> _Hash: ...
  40      def sha384(__string: ReadableBuffer = ...) -> _Hash: ...
  41      def sha512(__string: ReadableBuffer = ...) -> _Hash: ...
  42  
  43  def new(name: str, data: ReadableBuffer = ...) -> _Hash: ...
  44  
  45  algorithms_guaranteed: AbstractSet[str]
  46  algorithms_available: AbstractSet[str]
  47  
  48  def pbkdf2_hmac(
  49      hash_name: str, password: ReadableBuffer, salt: ReadableBuffer, iterations: int, dklen: Optional[int] = ...
  50  ) -> bytes: ...
  51  
  52  class _VarLenHash(object):
  53      digest_size: int
  54      block_size: int
  55      name: str
  56      def __init__(self, data: ReadableBuffer = ...) -> None: ...
  57      def copy(self) -> _VarLenHash: ...
  58      def digest(self, __length: int) -> bytes: ...
  59      def hexdigest(self, __length: int) -> str: ...
  60      def update(self, __data: ReadableBuffer) -> None: ...
  61  
  62  sha3_224 = _Hash
  63  sha3_256 = _Hash
  64  sha3_384 = _Hash
  65  sha3_512 = _Hash
  66  shake_128 = _VarLenHash
  67  shake_256 = _VarLenHash
  68  
  69  def scrypt(
  70      password: ReadableBuffer,
  71      *,
  72      salt: Optional[ReadableBuffer] = ...,
  73      n: Optional[int] = ...,
  74      r: Optional[int] = ...,
  75      p: Optional[int] = ...,
  76      maxmem: int = ...,
  77      dklen: int = ...,
  78  ) -> bytes: ...
  79  
  80  class _BlakeHash(_Hash):
  81      MAX_DIGEST_SIZE: int
  82      MAX_KEY_SIZE: int
  83      PERSON_SIZE: int
  84      SALT_SIZE: int
  85  
  86      if sys.version_info >= (3, 9):
  87          def __init__(
  88              self,
  89              __data: ReadableBuffer = ...,
  90              *,
  91              digest_size: int = ...,
  92              key: ReadableBuffer = ...,
  93              salt: ReadableBuffer = ...,
  94              person: ReadableBuffer = ...,
  95              fanout: int = ...,
  96              depth: int = ...,
  97              leaf_size: int = ...,
  98              node_offset: int = ...,
  99              node_depth: int = ...,
 100              inner_size: int = ...,
 101              last_node: bool = ...,
 102              usedforsecurity: bool = ...,
 103          ) -> None: ...
 104      else:
 105          def __init__(
 106              self,
 107              __data: ReadableBuffer = ...,
 108              *,
 109              digest_size: int = ...,
 110              key: ReadableBuffer = ...,
 111              salt: ReadableBuffer = ...,
 112              person: ReadableBuffer = ...,
 113              fanout: int = ...,
 114              depth: int = ...,
 115              leaf_size: int = ...,
 116              node_offset: int = ...,
 117              node_depth: int = ...,
 118              inner_size: int = ...,
 119              last_node: bool = ...,
 120          ) -> None: ...
 121  
 122  blake2b = _BlakeHash
 123  blake2s = _BlakeHash
 124