Parse RSA Key Pair From String In Python
I'm trying to generate/read a RSA-keypair from the publicKey and the privateKey as a String. Something like this: priK = '-----BEGIN RSA PRIVATE KEY-----MIIBOQIBAAJAVJhUS0gLqXLOmV
Solution 1:
RSA.importKey(key)
imports one key. It cannot import concatenated keys.
If you import a private key, then you can extract a public key from that, because common PKCS#1 and PKCS#8 format have all the necessary information to create public key. So, you don't even need to concatenate the public key to it.
Use:
privateKey = RSA.importKey(priK)
publicKey = privateKey.publickey()
Post a Comment for "Parse RSA Key Pair From String In Python"