I have used the below example for encrypting and decrypting some text in python and it works:
RSA encryption and decryption in Python
However when I write the private key to a file for future use and then import it to decrpyt some text I get:
"ValueError: RSA key format is not supported."
I have exported the private key to a file using:
privkey = key.exportKey()
f= open("/home/sam/samomate.pem","w+")
f.write(privkey)
f.close()
Try to import it using:
pkey = f.read()
keyDER = b64decode(pkey)
privkey=RSA.importKey(keyDER, passphrase=None)
I added the base64 decode on the back of googleing the error to no avail.
Any assistance on this or better alternatives would be greatly appreciated.
Cheers