\Horde_Crypt_Blowfish

Provides blowfish encryption/decryption, with or without a secret key, for PHP strings.

Summary

Methods
Properties
Constants
__construct()
__get()
encrypt()
decrypt()
setKey()
$cipher
$key
$iv
IGNORE_OPENSSL
IGNORE_MCRYPT
BLOCKSIZE
MAXKEYSIZE
IV_LENGTH
No protected methods found
$_crypt
N/A
No private methods found
No private properties found
N/A

Constants

IGNORE_OPENSSL

IGNORE_OPENSSL

IGNORE_MCRYPT

IGNORE_MCRYPT

BLOCKSIZE

BLOCKSIZE

MAXKEYSIZE

MAXKEYSIZE

IV_LENGTH

IV_LENGTH

Properties

$cipher

$cipher : string

The cipher block mode ('ecb' or 'cbc').

Type

string

$key

$key : string

The encryption key in use.

Type

string

$iv

$iv : mixed

The initialization vector (false if using 'ecb').

Type

mixed

Methods

__construct()

__construct(string  $key, array  $opts = array()) 

Constructor.

Parameters

string $key

Encryption key.

array $opts

Additional options:

  • cipher: (string) Either 'ecb' or 'cbc'.
  • ignore: (integer) A mask of drivers to ignore (IGNORE_* constants).
  • iv: (string) IV to use.

__get()

__get(  $name) 

Parameters

$name

encrypt()

encrypt(string  $text) : string

Encrypts a string.

Parameters

string $text

The string to encrypt.

Throws

\Horde_Crypt_Blowfish_Exception

Returns

string —

The ciphertext.

decrypt()

decrypt(string  $text) : string

Decrypts a string.

Parameters

string $text

The string to decrypt.

Throws

\Horde_Crypt_Blowfish_Exception

Returns

string —

The plaintext.

setKey()

setKey(string  $key, string  $iv = null) 

Sets the secret key.

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

Parameters

string $key

Key must be non-empty and less than MAXKEYSIZE bytes in length.

string $iv

The initialization vector to use. Only needed for 'cbc' cipher. If null, an IV is automatically generated.

Throws

\Horde_Crypt_Blowfish_Exception