Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
util.py13 linesDownload Raw Back to core
1import hashlib2from authlib.common.encoding import to_bytes, urlsafe_b64encode3 4 5def create_half_hash(s, alg):6    hash_type = f'sha{alg[2:]}'7    hash_alg = getattr(hashlib, hash_type, None)8    if not hash_alg:9        return None10    data_digest = hash_alg(to_bytes(s)).digest()11    slice_index = int(len(data_digest) / 2)12    return urlsafe_b64encode(data_digest[:slice_index])13 
codekingpro/portable-devtools · Team Ai