Download encode_key.py from didodo11/VOX22: direct link, hf CLI and curl.
- Browser
- Download file 890 Bytes
-
https://huggingface.co/spaces/didodo11/VOX22/resolve/main/encode_key.py
- Command line
-
hf download hf://spaces/didodo11/VOX22/encode_key.py
-
curl -L -o encode_key.py https://huggingface.co/spaces/didodo11/VOX22/resolve/main/encode_key.py
890 Bytes
| """ | |
| encode_key.py — Generate encoded API key for ANI TTS server | |
| ============================================================ | |
| Usage: | |
| python encode_key.py my-secret-key-2024 | |
| Output: | |
| Encoded key: ==ANyMjAy... (paste this in ENCODED_API_KEY in app.py) | |
| """ | |
| import sys | |
| import base64 | |
| def encode_key(key: str) -> str: | |
| return base64.b64encode(key.encode()).decode()[::-1] | |
| def decode_key(encoded: str) -> str: | |
| return base64.b64decode(encoded[::-1]).decode() | |
| if __name__ == "__main__": | |
| if len(sys.argv) < 2: | |
| print("Usage: python encode_key.py <your-api-key>") | |
| sys.exit(1) | |
| key = sys.argv[1] | |
| encoded = encode_key(key) | |
| decoded = decode_key(encoded) | |
| print(f"\nOriginal key : {key}") | |
| print(f"Encoded key : {encoded}") | |
| print(f"Verify decode: {decoded}") | |
| print(f"\nPaste this in app.py:") | |
| print(f'ENCODED_API_KEY = "{encoded}"') | |