Documentation

Horde_Crypt_Blowfish
in package

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

Tags
author

Matthew Fonda mfonda@php.net

author

Michael Slusarz slusarz@horde.org

category

Horde

copyright

2005-2008 Matthew Fonda

copyright

2012-2017 Horde LLC

license

http://www.horde.org/licenses/lgpl21 LGPL 2.1

Table of Contents

BLOCKSIZE  = 8
IGNORE_MCRYPT  = 2
IGNORE_OPENSSL  = 1
IV_LENGTH  = 8
MAXKEYSIZE  = 56
$cipher  : string
$iv  : mixed
$key  : string
$_crypt  : Horde_Crypt_Blowfish_Base
Blowfish crypt driver.
__construct()  : mixed
Constructor.
__get()  : mixed
decrypt()  : string
Decrypts a string.
encrypt()  : string
Encrypts a string.
setKey()  : mixed
Sets the secret key.

Constants

IGNORE_MCRYPT

public mixed IGNORE_MCRYPT = 2

IGNORE_OPENSSL

public mixed IGNORE_OPENSSL = 1

Properties

$cipher

public string $cipher

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

$iv

public mixed $iv

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

$key

public string $key

The encryption key in use.

Methods

__construct()

Constructor.

public __construct(string $key[, array<string|int, mixed> $opts = array() ]) : mixed
Parameters
$key : string

Encryption key.

$opts : array<string|int, mixed> = array()

Additional options:

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

__get()

public __get(mixed $name) : mixed
Parameters
$name : mixed
Return values
mixed

decrypt()

Decrypts a string.

public decrypt(string $text) : string
Parameters
$text : string

The string to decrypt.

Tags
throws
Horde_Crypt_Blowfish_Exception
Return values
string

The plaintext.

encrypt()

Encrypts a string.

public encrypt(string $text) : string
Parameters
$text : string

The string to encrypt.

Tags
throws
Horde_Crypt_Blowfish_Exception
Return values
string

The ciphertext.

setKey()

Sets the secret key.

public setKey(string $key[, string $iv = null ]) : mixed

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

Parameters
$key : string

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

$iv : string = null

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

Tags
throws
Horde_Crypt_Blowfish_Exception
Return values
mixed

Search results