17 lines
678 B
Python
17 lines
678 B
Python
import secrets
|
|
import argparse
|
|
|
|
# Generates a long random hex key suitable for use as a client access key.
|
|
# Run this once per client (main/test/etc.) and put the result into:
|
|
# - server-side config.json (as the dict key, mapped to the folder)
|
|
# - updater.py CLIENT_KEYS (as the value, mapped to the display name)
|
|
|
|
if __name__ == "__main__":
|
|
parser = argparse.ArgumentParser(description="Generate a random hex access key for a client.")
|
|
parser.add_argument("--bytes", type=int, default=32,
|
|
help="Number of random bytes (default 32 -> 64 hex chars).")
|
|
args = parser.parse_args()
|
|
|
|
key = secrets.token_hex(args.bytes)
|
|
print(key)
|