Created
December 21, 2017 16:20
-
-
Save ismailakkila/096201fc35f6865273fea37cb4d83446 to your computer and use it in GitHub Desktop.
ch9_generate_keys.py
This file contains 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
#ch9_generate_keys.py | |
from Crypto.PublicKey import RSA | |
#Generate a public/ private key pair using 4096 bits key length (512 bytes) | |
new_key = RSA.generate(4096, e=65537) | |
#The private key in PEM format | |
private_key = new_key.exportKey("PEM") | |
#The public key in PEM Format | |
public_key = new_key.publickey().exportKey("PEM") | |
print private_key | |
fd = open("private_key.pem", "wb") | |
fd.write(private_key) | |
fd.close() | |
print public_key | |
fd = open("public_key.pem", "wb") | |
fd.write(public_key) | |
fd.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment