mirror of
https://github.com/th30d4y/ExecuTrace.git
synced 2026-05-26 11:35:51 +00:00
24 lines
469 B
Python
24 lines
469 B
Python
from __future__ import annotations
|
|
|
|
import hashlib
|
|
|
|
|
|
BLOCK_SIZE = 1024 * 64
|
|
|
|
|
|
def sha256_bytes(data: bytes) -> str:
|
|
digest = hashlib.sha256()
|
|
digest.update(data)
|
|
return digest.hexdigest()
|
|
|
|
|
|
def sha256_file(path: str) -> str:
|
|
digest = hashlib.sha256()
|
|
with open(path, "rb") as f:
|
|
while True:
|
|
block = f.read(BLOCK_SIZE)
|
|
if not block:
|
|
break
|
|
digest.update(block)
|
|
return digest.hexdigest()
|