Skip to content

Fix blake2 binding #1663

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 9, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 16 additions & 22 deletions stdlib/3/hashlib.pyi
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# Stubs for hashlib

import sys
from abc import abstractmethod, ABCMeta
from typing import AbstractSet, Optional, Union

_DataType = Union[bytes, bytearray, memoryview]

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

Expand All @@ -15,14 +14,12 @@ class _Hash(metaclass=ABCMeta):
# formally specified, so may not exist on some platforms
name = ... # type: str

@abstractmethod
def update(self, arg: _DataType) -> None: ...
@abstractmethod
def __init__(self, data: _DataType = ...) -> None: ...

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

def md5(arg: _DataType = ...) -> _Hash: ...
def sha1(arg: _DataType = ...) -> _Hash: ...
Expand All @@ -42,27 +39,24 @@ if sys.version_info >= (3, 4):
def pbkdf2_hmac(hash_name: str, password: _DataType, salt: _DataType, iterations: int, dklen: Optional[int] = ...) -> bytes: ...

if sys.version_info >= (3, 6):
class _VarLenHash(metaclass=ABCMeta):
class _VarLenHash(object):
digest_size = ... # type: int
block_size = ... # type: int
name = ... # type: str

@abstractmethod
def __init__(self, data: _DataType = ...) -> None: ...

def copy(self) -> _VarLenHash: ...
def digest(self, length: int) -> bytes: ...
@abstractmethod
def hexdigest(self, length: int) -> str: ...
@abstractmethod
def update(self, arg: _DataType) -> None: ...
@abstractmethod
def copy(self) -> _VarLenHash: ...

def sha3_224(arg: _DataType = ...) -> _Hash: ...
def sha3_256(arg: _DataType = ...) -> _Hash: ...
def sha3_384(arg: _DataType = ...) -> _Hash: ...
def sha3_512(arg: _DataType = ...) -> _Hash: ...

def shake_128(arg: _DataType = ...) -> _VarLenHash: ...
def shake_256(arg: _DataType = ...) -> _VarLenHash: ...
sha3_224 = _Hash
sha3_256 = _Hash
sha3_384 = _Hash
sha3_512 = _Hash
shake_128 = _VarLenHash
shake_256 = _VarLenHash

def scrypt(password: _DataType, *, salt: _DataType, n: int, r: int, p: int, maxmem: int = ..., dklen: int = ...) -> bytes: ...

Expand All @@ -72,7 +66,7 @@ if sys.version_info >= (3, 6):
PERSON_SIZE = ... # type: int
SALT_SIZE = ... # type: int

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: ...
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: ...

blake2b = _BlakeHash
blake2s = _BlakeHash