I am using RSA to encrypt/decrypt my session keys in Python. I am using Pycrypto library. After generating the keypair, I want to extract the private key and public key from that generated key and store them in different files. How can I do this? I can see the has Private method which can tell that the generated keypair has private component but not able to find how to extract both the keys from this generated keypair. Any Suggestion would be of great help.
Share
If you want to get the different parts from the key, there is
keyattribute for that:Available components are ‘n’, ‘e’, ‘d’, ‘p’, ‘q’, ‘u’
If you just want to save it in PEM, you should use
exportKey()method (available since 2.2)