I need to create a function that pick up the previous iteration in a loop. I'm starting with an initial value but then I don't know how to use the result for the next iteration visual
I've tried somethings like this but it doesn't seems to work at all
def CBC(P,K,iv):
crypted =[]
first_elem = XOR(XOR(P[0],iv),K)
crypted.append(first_elem) #inital value
print(crypted[0])
for i in range(0,len(P),1):
while i>0:
prev_crypted = crypted[i-1]
next_crypted = XOR(XOR(P[i],prev_crypted),K)
return next_crypted
print(CBC("hfkeifnskogf","K","I"))