7 lines
209 B
Python
7 lines
209 B
Python
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)
|