Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Xor the output from SDES

Hi again,

From the Stalling's cryptography textbook I use the xor function a following :

def XorBlock(block1, block2):

   r"""
   Xors two blocks together.
   """
   l = len(block1);
   if (l != len(block2)):
      raise ValueError, "XorBlock arguments must be same length"
   return [(block1[j]+block2[j]) % 2 for j in xrange(l)];

it works well when I use it to xor 2 blocks. But when I wanna xor the output from sDES function as following:

from sage.crypto.block_cipher.sdes import SimplifiedDES
sdes = SimplifiedDES()
T = [0,1,0,1,0,1,0,1]
K = [1, 0, 1, 0, 0, 0, 0, 0, 1, 0]
sdes.encrypt(T,K)
XorBlock(sdes.encrypt(T,K),T)

it will replies TypeError: unsupported operand parent(s) for '+': 'Free binary string monoid' and 'Integer Ring'

So, how could I store the sdes.encrypt(T,K) into a pure list so that the XorBlock could work???

Thank you !!!!