Files
api-gateway/cmd/api-key.py
2026-02-09 07:40:11 +01:00

20 lines
452 B
Python

import secrets
import uuid
import base64
from argon2 import PasswordHasher
new_secret = secrets.token_hex(32)
print(new_secret)
ph = PasswordHasher()
hashed_secret = ph.hash(new_secret)
new_id = uuid.uuid4()
plain_secret = f"{new_id}:{new_secret}"
base64_secret = base64.b64encode(plain_secret.encode()).decode()
print(f"Secret: {base64_secret}")
print(f"ID: {new_id}")
print(f"Hashed Secret: {hashed_secret}")
print(f"X-Api-Key: {base64_secret}")