From: Jordan Apgar on
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.
From: Legrandin on

> gkey = RSA.generate(384, Random.new().read)
> string = str((gkey.publickey().__getstate__(),(333,444)))

You are encrypting with RSA a piece of data which is way
larger than the key size (48 bytes).

From: Jordan Apgar on
On Feb 9, 1:27 pm, Legrandin <pheenso...(a)farifluset.mailexpire.com>
wrote:
> > gkey = RSA.generate(384, Random.new().read)
> > string = str((gkey.publickey().__getstate__(),(333,444)))
>
> You are encrypting with RSA a piece of data which is way
> larger than the key size (48 bytes).

ah thanks Legrandin