Forked from lkdocs/Python PyCrypto: Generate RSA Keys Example.py
Created
August 19, 2018 16:22
-
-
Save ahmed-bhs/00b662f8ac71fa17bc8a041362e08c91 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
def generate_RSA(bits=2048): | |
''' | |
Generate an RSA keypair with an exponent of 65537 in PEM format | |
param: bits The key length in bits | |
Return private key and public key | |
''' | |
from Crypto.PublicKey import RSA | |
new_key = RSA.generate(bits, e=65537) | |
public_key = new_key.publickey().exportKey("PEM") | |
private_key = new_key.exportKey("PEM") | |
return private_key, public_key |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment