Attributeerror _rsaobj object has no 'export key' attribute

Viewed 442

I tried to create and store public and private key with python.

My code same as official document. But I get Attribute Error.

from Crypto.PublicKey import RSA

key = RSA.generate(2048)
private_key = key.export_key() <-----------------------------------------Error Line
file_out = open("private.pem", "wb")
file_out.write(private_key)
file_out.close()

Output :

Attributeerror _rsaobj object has no 'export key' attribute
1 Answers

It seems you have Pycrypto, not Pycryptodome. If that is the case, exportKey should work, but it's best to uninstall and install Pycryptodome.

Related