imp/celeste/crypto/hash.py

8 lines
209 B
Python
Raw Permalink Normal View History

import hashlib
def sha256(data: bytes, as_bytes: bool = False) -> bytes:
hasher = hashlib.sha256()
hasher.update(data)
hash = hasher.digest()
return hash if as_bytes else int.from_bytes(hash)