CoolFace
Apppublic

hiropr/llm-code-deployment

sourceHugging Facemitupdated 11mo agoView on Hugging Face
0likes
helpers.py20 linesDownload Raw Back to root
1import hashlib2import re3import base644 5 6def hash_secret(s: str) -> str:7    """Return SHA256 hash of a given secret string."""8    return hashlib.sha256(s.encode()).hexdigest()9 10 11def decode_data_uri(uri: str):12    """Decode data URI (data:<mime>;base64,<content>)"""13    m = re.match(r"data:(.*?);base64,(.*)", uri)14    if not m:15        raise ValueError("Invalid data URI")16    mime = m.group(1)17    b64 = m.group(2)18    data = base64.b64decode(b64)19    return data, mime20