How add/change password for RSA priv key using PyCrypto

k2 grzegorz.tezycki at
Mon Aug 1 07:22:36 EDT 2011

Hi, maybe somebody be able to help me.
I'm using PyCrypto to generate a pair of RSA keys. The public key and
private key.
I try to add a password to the private key, and I do not know how to
do it.

This is a piece of my code.

from Crypto.PublicKey import RSA

private_alice_key = RSA.generate(1024)
public_alice_key  = private_alice_key.publickey()

str_priv = private_alice_key.exportKey()
str_pub  = public_alice_key.exportKey()

print str_priv
print str_pub

# HOW ADD OR CHANGE PASSWORD FOR private_alice_key

More information about the Python-list mailing list