SHA-2
SHA-2 digest algorithms.
Example
from oxcrypto.hash.sha2 import SHA2
algorithm = SHA2.SHA256
digest = algorithm.digest(b"hello")
assert digest == algorithm.digest_chunks([b"he", b"llo"])
hasher = algorithm.new()
hasher.update(b"he")
hasher.update(b"llo")
assert hasher.digest() == digest
print(digest.hex())Variants
SHA2.SHA224SHA2.SHA256SHA2.SHA384SHA2.SHA512SHA2.SHA512_224SHA2.SHA512_256
Methods
digest(self, data: bytes, /) -> bytes
digest_chunks(self, chunks: Iterable[bytes], /) -> bytes
new(self) -> Hasher