fork download
  1. def shiftRows(state):
  2. for i in range(4):
  3. state[i::4] = rotate(state[i::4],i)
  4.  
  5. def shiftRowsInv(state):
  6. for i in range(4):
  7. state[i::4] = rotate(state[i::4],-i)
  8.  
  9. def mixColumns(state):
  10. for i in range(4):
  11. column = []
  12. # create the column by taking the same item out of each "virtual" row
  13. for j in range(4):
  14. column.append(state[i*4+j])
  15.  
  16. # apply mixColumn on our virtual column
  17. mixColumn(column)
  18.  
  19. # transfer the new values back into the state table
  20. for j in range(4):
  21. state[i*4+j] = column[j]
  22.  
  23. def mixColumnsInv(state):
  24. for i in range(4):
  25. column = []
  26. # create the column by taking the same item out of each "virtual" row
  27. for j in range(4):
  28. column.append(state[i*4+j])
  29.  
  30. # apply mixColumn on our virtual column
  31. mixColumnInv(column)
  32.  
  33. # transfer the new values back into the state table
  34. for j in range(4):
  35. state[i*4+j] = column[j]
Success #stdin #stdout 0.01s 8968KB
stdin
Standard input is empty
stdout
Standard output is empty