Atualizar src-py/renatoxsr/utils/hash_b58.py
This commit is contained in:
@@ -7,6 +7,12 @@ import base58
|
||||
import os, sys, hashlib
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
from renatoxsr.logger import set_logger
|
||||
logger = set_logger(__name__)
|
||||
if "--debug" in sys.argv:
|
||||
logger.setLevel("DEBUG")
|
||||
|
||||
def hash_b58(src_arg: str | Path, hash_algo="sha256", output_print=True, output_stream=sys.stdout):
|
||||
src = Path(src_arg)
|
||||
with open(src, "rb") as f:
|
||||
@@ -15,6 +21,9 @@ def hash_b58(src_arg: str | Path, hash_algo="sha256", output_print=True, output_
|
||||
hash_b58 = base58.b58encode(hash.digest()).decode("utf-8")
|
||||
if output_print:
|
||||
output_stream.write(f"{hash_algo}:{hash_hex} {hash_b58} '{src}'\n")
|
||||
else:
|
||||
logger.info(f"%s:%s %s '%s'", hash_algo, hash_hex, hash_b58, src)
|
||||
return hash_b58
|
||||
|
||||
|
||||
def hash_recursive_b58(folder: str | Path, glob="*"):
|
||||
|
||||
Reference in New Issue
Block a user