Crypt_Blowfish
[ class tree: Crypt_Blowfish ] [ index: Crypt_Blowfish ] [ all elements ]

Class: Crypt_Blowfish_MCrypt

Source Location: /Crypt_Blowfish-1.1.0RC2/Blowfish/MCrypt.php

Class Overview

Crypt_Blowfish
   |
   --Crypt_Blowfish_MCrypt

Example using the factory method in CBC mode and forcing using the MCrypt library.


Author(s):

Version:

  • 1.1.0RC2

Copyright:

  • 2005-2008 Matthew Fonda

Methods


Inherited Variables

Inherited Methods

Class: Crypt_Blowfish

Crypt_Blowfish::Crypt_Blowfish()
Crypt_Blowfish Constructor Initializes the Crypt_Blowfish object (in EBC mode), and sets the secret key
Crypt_Blowfish::decrypt()
Decrypts an encrypted string
Crypt_Blowfish::encrypt()
Encrypts a string
Crypt_Blowfish::factory()
Crypt_Blowfish object factory
Crypt_Blowfish::getBlockSize()
Returns the algorithm's block size
Crypt_Blowfish::getIVSize()
Returns the algorithm's IV size
Crypt_Blowfish::getMaxKeySize()
Returns the algorithm's maximum key size
Crypt_Blowfish::init()
Deprecated init method - init is now a private method and has been replaced with _init
Crypt_Blowfish::isReady()
Deprecated isReady method
Crypt_Blowfish::setKey()
Sets the secret key The key must be non-zero, and less than or equal to 56 characters (bytes) in length.

Class Details

[line 53]
Example using the factory method in CBC mode and forcing using the MCrypt library.

  1.  $bf =Crypt_Blowfish::factory('cbc'nullnullCRYPT_BLOWFISH_MCRYPT);
  2.  if (PEAR::isError($bf)) {
  3.      echo $bf->getMessage();
  4.      exit;
  5.  }
  6.  $iv 'abc123+=';
  7.  $key 'My secret key';
  8.  $bf->setKey($key$iv);
  9.  $encrypted $bf->encrypt('this is some example plain text');
  10.  $bf->setKey($key$iv);
  11.  $plaintext $bf->decrypt($encrypted);
  12.  echo "plain text: $plaintext";



[ Top ]


Method Detail

Crypt_Blowfish_MCrypt (Constructor)   [line 72]

Crypt_Blowfish_MCrypt Crypt_Blowfish_MCrypt( [string $key = null], [string $mode = 'ecb'], [string $iv = null])

Crypt_Blowfish Constructor Initializes the Crypt_Blowfish object, and sets the secret key
  • Access: public

Parameters:

string   $key     
string   $mode     operating mode 'ecb', 'cbc'...
string   $iv     initialization vector

[ Top ]

decrypt   [line 128]

string|PEAR_Error decrypt( string $cipherText)

Decrypts an encrypted string

The value was padded with NUL characters when encrypted. You may need to trim the result or cast its type.

  • Return: Returns plain text on success, or PEAR_Error on failure
  • Access: public

Overrides Crypt_Blowfish::decrypt() (Decrypts an encrypted string)

Parameters:

string   $cipherText     

[ Top ]

encrypt   [line 107]

string|PEAR_Error encrypt( string $plainText)

Encrypts a string

Value is padded with NUL characters prior to encryption. You may need to trim or cast the type when you decrypt.

  • Return: Returns cipher text on success, or PEAR_Error on failure
  • Access: public

Overrides Crypt_Blowfish::encrypt() (Encrypts a string)

Parameters:

string   $plainText     string of characters/bytes to encrypt

[ Top ]

setKey   [line 150]

boolean|PEAR_Error setKey( string $key, [string $iv = null])

Sets the secret key The key must be non-zero, and less than or equal to 56 characters (bytes) in length.

If you are making use of the PHP mcrypt extension, you must call this method before each encrypt() and decrypt() call.

  • Return: Returns TRUE on success, PEAR_Error on failure
  • Access: public

Overrides Crypt_Blowfish::setKey() (Sets the secret key The key must be non-zero, and less than or equal to 56 characters (bytes) in length.)

Parameters:

string   $key     
string   $iv     8-char initialization vector (required for CBC mode)

[ Top ]


Documentation generated on Sat, 30 Aug 2008 18:00:07 -0400 by phpDocumentor 1.4.0. PEAR Logo Copyright © PHP Group 2004.