/** * Initial Permutation (IP) * Now we encode each 64-bit block of data. There is an initial permutation IP of * the 64 bits of the message data M. This rearranges the bits according to the * following table, where the entries in the table show the new arrangement of the * bits from their initial order. The 58th bit of M becomes the first bit of IP. * The 50th bit of M becomes the second bit of IP. The 7th bit of M is the last * bit of IP. * * According to the book Applied Cryptography (Bruce Schneier, 2nd edition, pg. 271): * The initial permution was used to make it easier to load plain text and cipher text * data into a DES chip in byte-sized pieces when doing DES in hardware. The IP and FP * are not necessary in software implementations and do not affect the security. However, * the IP and FP are part of the DES standard and not implementing it would deviate from * the standard, so we will do it here in phpCrypt. * * @param string $m The plain text message * @return array the Initial Permutation (IP) */ private function ip($text) { $text = parent::str2Bin($text); $ip = ""; // loop through the 64 bit block, ordering it occording to $_ip for ($i = 0; $i < 64; ++$i) { $ip .= $text[self::$_ip[$i] - 1]; } return $ip; }