COSCUP-ap-demo/misc.py
SouthFox 29cc7017cb
Some checks failed
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/test Pipeline failed
[lint] disable W0511(fixme)
- unused-import
- wrong-import-order
2023-07-12 00:56:58 +08:00

24 lines
484 B
Python

#!/usr/bin/env python3
"""Something misc."""
import sys
import click
from Crypto.PublicKey import RSA
from demo import config
@click.command()
def gen_key():
"""Generate key."""
if config.KEY_PATH.exists():
print("Key is existing!")
sys.exit(2)
else:
k = RSA.generate(2048)
privkey_pem = k.exportKey("PEM").decode("utf-8")
config.KEY_PATH.write_text(privkey_pem)
print("Done!")
if __name__ == "__main__":
gen_key()