Files
eculocate/genkeys.py
T
2026-02-15 17:57:07 +00:00

18 lines
472 B
Python

import nacl
from pathlib import Path
from nacl.public import PrivateKey, Box
import sys
secret = PrivateKey.generate()
public = secret.public_key
sk_filename = Path(sys.argv[1])
sk_filename.parent.mkdir(exist_ok=True)
with open(sk_filename, "w") as f:
f.buffer.write(secret.encode(encoder=nacl.encoding.RawEncoder))
pk_filename = sk_filename.with_suffix(".pub")
with open(pk_filename, "w") as f:
f.buffer.write(public.encode(encoder=nacl.encoding.RawEncoder))