예제 #1
0
 /**
  * Applies the Sbox to each byte of the string passed in.
  * This is similar to subByte(), but Unlike subByte() we do not use
  * the _s_inv[] table. This function is only used in expandKey(),
  * which is implemented by the class that inherits this class
  *
  * @param string $text The string to peform the byte subsitution
  * @return string The string with the subsituted bytes
  */
 private function subWord(&$text)
 {
     $max = strlen($text);
     for ($i = 0; $i < $max; ++$i) {
         // the sbox is arrange in a 16 x 16 grid, where each row
         // and column is numbered in hex (from 0 - f)
         $hex = parent::str2Hex($text[$i]);
         $row = parent::hex2Dec($hex[0]);
         $col = parent::hex2Dec($hex[1]);
         $pos = $row * 16 + $col;
         $text[$i] = chr(self::$_s[$pos]);
     }
 }