From f5bfee6f3509fcbd9470e7b3e2118130a5909c38 Mon Sep 17 00:00:00 2001 From: Jakub Stasiak Date: Wed, 4 May 2016 17:29:16 +0200 Subject: [PATCH] Finish Python 3 hashlib stub (#179) --- stdlib/3/hashlib.pyi | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/stdlib/3/hashlib.pyi b/stdlib/3/hashlib.pyi index ee8b235ab..4d3709b20 100644 --- a/stdlib/3/hashlib.pyi +++ b/stdlib/3/hashlib.pyi @@ -1,11 +1,17 @@ # Stubs for hashlib -# NOTE: These are incomplete! - from abc import abstractmethod, ABCMeta -import typing +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 @@ -23,3 +29,12 @@ 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: ...