Skip to content

Instantly share code, notes, and snippets.

@febimudiyanto
Created February 13, 2022 16:02
Show Gist options
  • Save febimudiyanto/52f248002f3c629d3fee8077ac98d9fc to your computer and use it in GitHub Desktop.
Save febimudiyanto/52f248002f3c629d3fee8077ac98d9fc to your computer and use it in GitHub Desktop.
'''
pip install pycryptodome
'''
from Crypto.PublicKey import RSA
key = RSA.generate(2048)
privateKey = key.export_key()
publicKey = key.publickey().export_key()
# save private key to file
with open('private.pem', 'wb') as f:
f.write(privateKey)
# save public key to file
with open('public.pem', 'wb') as f:
f.write(publicKey)
print('Private key saved to private.pem')
print('Public key saved to public.pem')
print('Done')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment