[Tutor] Cryptography Toolkit

Kent Johnson kent37 at tds.net
Fri Apr 1 13:45:25 CEST 2005


It works if you make a new XOR object for the decryption:

from Crypto.Cipher import XOR

obj_xor = XOR.new("string")
str_encrypt = "encrypt this string"
print str_encrypt

xored = obj_xor.encrypt(str_encrypt)
print xored

obj_xor = XOR.new("string")
print obj_xor.decrypt(xored)

Kent

Mark Thomas wrote:
> On Thu, 31 Mar 2005 09:14:03 -0500, Kent Johnson <kent37 at tds.net> wrote:
> 
>>If you post your code and the complete error message including the stack trace we may be able to help.
>>
>>Kent
> 
> 
> Thanks Ken
> 
> I'm getting closer to making this work using the XOR cipher. Here's
> what I'm doing.
> 
> <from python>
> 
> from Crypto.Cipher import XOR
> 
> obj_xor = XOR.new("string")
> str_encrypt = "encrypt this string"
> xored = obj_xor.encrypt(str_encrypt)
> xored
> '\x16\x1a\x11\x1b\x17\x17\x07T\x06\x01\x07\x14S\x07\x06\x1b\x07\t\x14'
> obj_xor.decrypt(xored)
> "bhxupds&oo`g'uou`z`" <== *confused by this output*
> 
> </from python>
> 
> Close but no cigar!! *grin*
> 



More information about the Tutor mailing list