Is it possible to use public functions inside a public function in php?
I got a few public functions which change the input and return it. I want to make a for statement inside a public function that loops through my functions, like:
$input
for= function1 -> output1 -> function2->output2->function3->output3.
I want to use the output of that for my next function. Also the 4 functions I have in my for loop has to loop 9 times.
in this case its about AES encrypt. i got 4 functions called: subBytes, shiftRows, mixColumns, addRoundkey.
This is my public function encrypt:
public function encrypt($input)
{
$functions= ('subBytes', 'shiftRows', 'mixColumns', 'addRoundKey' );
foreach($functions as $function)
{
$input = $$function($input);
}
return($input);
} //end function encrypt
and this is one of my functions:
public function subBytes($state)
{
for ($row=0; $row<4; $row++){ // for all 16 bytes in the (4x4-byte) State
for ($column=0; $column<4; $column++){ // for all 16 bytes in the (4x4-byte) State
$_SESSION['debug'] .= "state[$row][$column]=" . $state[$row][$column] ."-->" . self::$sBox[$state[$row][$column]]."
";
$state[$row][$column] = self::$sBox[$state[$row][$column]];
}
}
return $state;
}