I am working on DES algorithm in Python.
In one of the functions namely Fiestle function, I have to XOR elements to get the cypher.
Is there any way I can perform shifting operation in python ,Below is the code that I tried:
C0 is 1111000011001100101010101111
D0 is 0101010101100110011110001111
c0_d0=[]
for i in range(1):
t=[]
t.append(C0)
t.append(D0)
c0_d0.append(t)
#print c0_d0
def str_to_bin(strr,shifts):
for i in range(1,17):
temp=[]
for j in range(1):
temp.append(int(c0_d0[i-1][0])<<1)
temp.append(int(c0_d0[i-1][1])<<1)
c0_d0.append(temp)
return c0_d0
I want the elements to be a binary string obtained by shifting bits.That is first element pair is obtained by shifting the previous element pair and next element pair is obtained by previous element and so on.Only 0th index element are given.
Example C0 is 1111000011001100101010101111 D0 is 0101010101100110011110001111
C1 should be C0<<1 which is equal to 1110000110011001010101011110
D1 should be D0<<1 which is equal to 1010101011001100111100011110

C1 = C0[1:]+"0". But your question is really unclear.