Buckets:

download
raw
666 Bytes
import hashlib
import secrets
import string
def generate_api_key(length: int = 40) -> str:
"""Generate a secure random API key string.
Args:
length (int): Length of the API key.
Returns:
str: The generated API key (plaintext).
"""
alphabet = string.ascii_letters + string.digits
return "".join(secrets.choice(alphabet) for _ in range(length))
def hash_api_key(api_key: str) -> str:
"""Hash an API key using SHA-256.
Args:
api_key (str): The plaintext API key.
Returns:
str: The hex-encoded SHA-256 hash of the API key.
"""
return hashlib.sha256(api_key.encode("utf-8")).hexdigest()

Xet Storage Details

Size:
666 Bytes
·
Xet hash:
687639e13a2c57882074eddf30721f563573ece496222ae739c01bffb20035e3

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.