Reputation:
msg = "this is msg to encrypt"
pub_key = M2Crypto.RSA.load_pub_key('mykey.py') // This method is taking PEM file.
encrypted = pub_key.public_encrypt(msg, M2Crypto.RSA.pkcs1_padding)
Now I am trying to give file containing radix64 format public key as a parameter in this method and unable to get expected result i.e encryption using radix64 format public key.
Is there any other method in the Python API which can encrypt msg using public key after trying some mechanism?
I am getting my public key from public key server with some HTML wrapping and in radix64 format. How can I convert the public key so that it can be accepted by any encryption method?
Upvotes: 5
Views: 5104
Reputation: 414
In case someone searches for this question, I was getting the same error message:
M2Crypto.RSA.RSAError: no start line
In my case, it turned out that my keys were of type unicode. This was solved by converting the key back to ascii:
key.encode('ascii')
Upvotes: 6
Reputation: 87054
There is an error somewhere in the public key. It appears to be a PGP public key but with different line lengths, so it can't be used directly as an RSA public key.
Upvotes: 0
Reputation: 75456
Did you ask this question before? See my answer to this question,
how to convert base64 /radix64 public key to a pem format in python
Upvotes: 1