code: def cipher(rkey, pt, Nk=4):
      
      assert Nk in {4, 6, 8}
      Nr = Nk + 6
  
      rkey = rkey.reshape(4*(Nr+1), 32)
      pt = pt.reshape(128)
  
      # first round
      state = add_round_key(pt, rkey[0:4])
  
      for i in range(1, Nr):
          state = sub_bytes(state)
          state = shift_rows(state)
          state = mix_columns(state)
          state = add_round_key(state, rkey[4*i:4*(i+1)])
  
      # final round
      state = sub_bytes(state)
      state = shift_rows(state)
      state = add_round_key(state, rkey[4*Nr:4*(Nr+1)])
  
      return state
docs: AES encryption cipher.