Logo Search packages:      
Sourcecode: ldap-account-manager version File versions

Cipher_blowfish::encrypt ( data,
key = null 
)

Encrypt a string of data.

Parameters:
String $data The string to encrypt
optional String $key The key to use
Returns:
String the encrypted output

Definition at line 408 of file blowfish.inc.

References encryptBlock().

                                         {
      // add end marker
      $data .= 'x';
      // split data to array of encryptable blocks
      $data_blocks = array();
      for ($j = 0; $j < strlen($data); $j = $j + 8) {
        $data_blocks[] = substr($data, $j, 8);
      }
      // add spaces to last block if needed
      $data_blocks[sizeof($data_blocks) - 1] = str_pad($data_blocks[sizeof($data_blocks) - 1], 8);
      // encrypt blocks
      $crypt_blocks = array();
      for ($i = 0; $i < sizeof($data_blocks); $i++) {
        $crypt_blocks[] = $this->encryptBlock($data_blocks[$i], $key);
      }
      return implode("", $crypt_blocks);
    }


Generated by  Doxygen 1.6.0   Back to index