$states = array(); foreach ($bytearrays as $bytearray) { $state = $iop->getState($bytearray); array_push($states, $state); } //put key in 4x4 byte array too //$key = $iop->getState($keyarray); // perform a subBytes operation $aesops = new Aes(); $_SESSION['debug'] .= "\nThe " . $operation . " operation:\n"; switch ($operation) { case "subBytes": $result = $aesops->subBytes($state); break; case "shiftRows": $result = $aesops->shiftRows($state); break; case "mixColumns": $result = $aesops->mixColumns($state); break; case "addRoundKey": $w = $aesops->keyExpansion($key); //generate roundkeys in key expansion $result = $aesops->addRoundKey($state, $w, 0); //add roundkey 0 for this example break; case "encrypt": if ($_POST['mode'] == 'ecb') { foreach ($states as $state) { array_push($results, $aesops->encrypt($state, $key)); }