4-variable-simplifier/python/sha256.py
2026-04-25 16:00:10 -04:00

13 lines
281 B
Python

import hashlib
def sha256(x):
return hashlib.sha256(repr(x).encode()).hexdigest()
def sha256_file(path):
try:
with open(path, "rb") as stream:
return hashlib.sha256(stream.read()).hexdigest()
except FileNotFoundError:
return hashlib.sha256(b"").hexdigest()