import hashlib def hash_secret(*data) -> bytes: """A custom HMAC that securily combines and hashes the given data (context, secrets). The first argument should be a namespacing string.""" inner = bytearray(len(data).to_bytes(8, "big")) for d in data: if isinstance(d, str): d = d.encode() inner += hashlib.sha256(d).digest() return hashlib.sha256(inner).digest()[:12]