Pycrypto RSA ciphertext to string back to ciphertext issue
Jordan Apgar
twistedphrame at gmail.com
Thu Feb 11 20:27:58 EST 2010
Hey all,
I'm trying to convert the encrypted data from RSA to a string for
sending over xmlrpc and then back to usable data. Whenever I decrypt
I just get junk data. Has anyone else tried doing this? Here's some
example code:
from Crypto.PublicKey import RSA
from Crypto import Random
key = RSA.generate(384, Random.new().read)
l = str(key.encrypt("dog",""))
l = stringToTuple(l)
l = key.decrypt(tuple(l))
print l
string to tuple:
def stringToTuple(string):
if string[0] + string[-1] == "()":
items = string[1:-1]
items = items.split(',')
return items
else:
raise ValueError("Badly formatted string (missing brackets).")
thanks for any help, I've been messing with this for days and have
come up dry.
More information about the Python-list
mailing list