Created
February 13, 2022 16:02
-
-
Save febimudiyanto/52f248002f3c629d3fee8077ac98d9fc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
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