0

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"))

  • More generally: https://stackoverflow.com/questions/231767/what-does-the-yield-keyword-do – mkrieger1 Oct 26 '20 at 10:54
  • Replace your `while` with an `if` ? As it stands, your `while` loop is infinite as `i` is not changed within it. – Wololo Oct 26 '20 at 10:59

0 Answers0