Attributeerror _rsaobj object has no 'export key' attribute

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

Upvotes: 2

Views: 866

Answers (1)

tohatsu
tohatsu

Reputation: 115

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

Upvotes: 2

Related Questions