build_signed_custom_id
Function
custom_id signed with HMAC-SHA256, with optional expiry. Cannot be forged without the secret.
from discord_interactions import build_signed_custom_idSignature
def build_signed_custom_id( base_id: str, data: Dict[str, Any] | None, secret: str, ttl_seconds: int | None = None, max_length: int = 100,) -> strParameters
| Name | Type | Default | Description |
|---|---|---|---|
base_id | str | required | |
data | Dict[str, Any] | None | required | |
secret | str | required | The bot's secret key. |
ttl_seconds | int | None | None | Validity in seconds. |
max_length | int | 100 |
Returns
str
Example
from discord_interactions import build_signed_custom_id, parse_signed_custom_id custom_id = build_signed_custom_id("retrait", {"montant": 500}, secret=SECRET, ttl_seconds=120)base_id, data, valide, raison = parse_signed_custom_id(custom_id, SECRET)