MinerU / magic_pdf /libs /hash_utils.py
derful's picture
Upload folder using huggingface_hub
240e0a0 verified
raw
history blame contribute delete
404 Bytes
import hashlib
def compute_md5(file_bytes):
hasher = hashlib.md5()
hasher.update(file_bytes)
return hasher.hexdigest().upper()
def compute_sha256(input_string):
hasher = hashlib.sha256()
# 在Python3中,需要将字符串转化为字节对象才能被哈希函数处理
input_bytes = input_string.encode('utf-8')
hasher.update(input_bytes)
return hasher.hexdigest()