Pycrypto RSA Issue

Jordan Apgar twistedphrame at gmail.com
Tue Feb 9 13:09:53 EST 2010


I am trying to encrypt public data along with another tuple and then
decrypt it after sending. RSA is needed for negotiation of keys for
AES. But I just get garbage after I decrypt it. This is what I'm
attempting to do:

from Crypto.PublicKey import RSA
from Crypto import Random

gkey = RSA.generate(384, Random.new().read)
string = str((gkey.publickey().__getstate__(),
              (333,444)))
print string
print
data = gkey.encrypt(string,"")
print "data:",data
print
print "decrypt"
print "decrypt,", gkey.decrypt(data)
print "done"

All I get are junk values when printing the decrypted value.



More information about the Python-list mailing list