File: hashlib.pyi

package info (click to toggle)
mypy 0.470-complete-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 5,864 kB
  • ctags: 3,264
  • sloc: python: 21,838; makefile: 18
file content (40 lines) | stat: -rw-r--r-- 1,369 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# Stubs for hashlib

from abc import abstractmethod, ABCMeta
from typing import AbstractSet

class Hash(metaclass=ABCMeta):
    digest_size = ...  # type: int
    block_size = ...  # type: int

    # [Python documentation note] Changed in version 3.4: The name attribute has
    # been present in CPython since its inception, but until Python 3.4 was not
    # formally specified, so may not exist on some platforms
    name = ...  # type: str

    @abstractmethod
    def update(self, arg: bytes) -> None: ...
    @abstractmethod
    def digest(self) -> bytes: ...
    @abstractmethod
    def hexdigest(self) -> str: ...
    @abstractmethod
    def copy(self) -> 'Hash': ...

def md5(arg: bytes = ...) -> Hash: ...
def sha1(arg: bytes = ...) -> Hash: ...
def sha224(arg: bytes = ...) -> Hash: ...
def sha256(arg: bytes = ...) -> Hash: ...
def sha384(arg: bytes = ...) -> Hash: ...
def sha512(arg: bytes = ...) -> Hash: ...

def new(name: str, data: bytes = ...) -> Hash: ...

# New in version 3.2
algorithms_guaranteed = ...  # type: AbstractSet[str]
algorithms_available = ...  # type: AbstractSet[str]

# New in version 3.4
# TODO The documentation says "password and salt are interpreted as buffers of
# bytes", should we declare something other than bytes here?
def pbkdf2_hmac(name: str, password: bytes, salt: bytes, rounds: int, dklen: int = ...) -> bytes: ...