[feat] gen key script
This commit is contained in:
parent
a8aa5105ab
commit
98f5e47dd8
1 changed files with 24 additions and 0 deletions
24
misc.py
Normal file
24
misc.py
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Something misc."""
|
||||||
|
import click
|
||||||
|
import sys
|
||||||
|
|
||||||
|
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()
|
Loading…
Reference in a new issue