PHP Class phpseclib\Crypt\RC2

Inheritance: extends phpseclib\Crypt\Common\BlockCipher
Exibir arquivo Open project: phpseclib/phpseclib Class Usage Examples

Public Properties

Property Type Description
$block_size integer Block Length of the cipher
$cfb_init_len integer Optimizing value while CFB-encrypting
$cipher_name_mcrypt string The mcrypt specific name of the cipher
$current_key_length integer The key length in bits.
$default_key_length integer The key length in bits.
$invpitable array Inverse key expansion randomization table.
$key string The Key
$key_length integer Key Length (in bytes)
$keys array The Key Schedule
$orig_key string The Original (unpadded) Key
$pitable array Twice the same 256-value sequence to save a modulus in key expansion.
$skip_key_adjustment boolean Don't truncate / null pad key

Public Methods

Method Description
__construct ( integer $mode ) Default Constructor.
_decryptBlock ( string $in ) : string Decrypts a block
_encryptBlock ( string $in ) : string Encrypts a block
_setupInlineCrypt ( ) Setup the performance-optimized function for de/encrypt()
_setupKey ( ) Creates the key schedule
_setupMcrypt ( ) Setup the \phpseclib\Crypt\Common\SymmetricKey::ENGINE_MCRYPT $engine
decrypt ( string $ciphertext ) : string Decrypts a message.
encrypt ( string $plaintext ) : string Encrypts a message.
getKeyLength ( ) : integer Returns the current key length
isValidEngine ( integer $engine ) : boolean Test for engine validity
setKey ( string $key, integer $t1 = false ) Sets the key.
setKeyLength ( integer $length ) Sets the key length.

Method Details

__construct() public method

Default Constructor.
public __construct ( integer $mode )
$mode integer

_decryptBlock() public method

Decrypts a block
See also: phpseclib\Crypt\Common\SymmetricKey::_decryptBlock()
See also: phpseclib\Crypt\Common\SymmetricKey::decrypt()
public _decryptBlock ( string $in ) : string
$in string
return string

_encryptBlock() public method

Encrypts a block
See also: phpseclib\Crypt\Common\SymmetricKey::_encryptBlock()
See also: phpseclib\Crypt\Common\SymmetricKey::encrypt()
public _encryptBlock ( string $in ) : string
$in string
return string

_setupInlineCrypt() public method

Setup the performance-optimized function for de/encrypt()
See also: phpseclib\Crypt\Common\SymmetricKey::_setupInlineCrypt()
public _setupInlineCrypt ( )

_setupKey() public method

Creates the key schedule
See also: phpseclib\Crypt\Common\SymmetricKey::_setupKey()
public _setupKey ( )

_setupMcrypt() public method

Setup the \phpseclib\Crypt\Common\SymmetricKey::ENGINE_MCRYPT $engine
See also: phpseclib\Crypt\Common\SymmetricKey::_setupMcrypt()
public _setupMcrypt ( )

decrypt() public method

Mostly a wrapper for \phpseclib\Crypt\Common\SymmetricKey::decrypt, with some additional OpenSSL handling code
See also: self::encrypt()
public decrypt ( string $ciphertext ) : string
$ciphertext string
return string $plaintext

encrypt() public method

Mostly a wrapper for \phpseclib\Crypt\Common\SymmetricKey::encrypt, with some additional OpenSSL handling code
See also: self::decrypt()
public encrypt ( string $plaintext ) : string
$plaintext string
return string $ciphertext

getKeyLength() public method

Returns the current key length
public getKeyLength ( ) : integer
return integer

isValidEngine() public method

This is mainly just a wrapper to set things up for \phpseclib\Crypt\Common\SymmetricKey::isValidEngine()
See also: phpseclib\Crypt\Common\SymmetricKey::__construct()
public isValidEngine ( integer $engine ) : boolean
$engine integer
return boolean

setKey() public method

Keys can be of any length. RC2, itself, uses 8 to 1024 bit keys (eg. strlen($key) <= 128), however, we only use the first 128 bytes if $key has more then 128 bytes in it, and set $key to a single null byte if it is empty.
See also: phpseclib\Crypt\Common\SymmetricKey::setKey()
public setKey ( string $key, integer $t1 = false )
$key string
$t1 integer optional Effective key length in bits.

setKeyLength() public method

Valid key lengths are 8 to 1024. Calling this function after setting the key has no effect until the next \phpseclib\Crypt\RC2::setKey() call.
public setKeyLength ( integer $length )
$length integer in bits

Property Details

$block_size public_oe property

Block Length of the cipher
See also: phpseclib\Crypt\Common\SymmetricKey::block_size
public int $block_size
return integer

$cfb_init_len public_oe property

Optimizing value while CFB-encrypting
See also: phpseclib\Crypt\Common\SymmetricKey::cfb_init_len
public int $cfb_init_len
return integer

$cipher_name_mcrypt public_oe property

The mcrypt specific name of the cipher
See also: phpseclib\Crypt\Common\SymmetricKey::cipher_name_mcrypt
public string $cipher_name_mcrypt
return string

$current_key_length public_oe property

The key length in bits.
See also: self::isValidEnine()
See also: self::setKey()
public int $current_key_length
return integer

$default_key_length public_oe property

The key length in bits.
See also: self::setKeyLength()
See also: self::setKey()
public int $default_key_length
return integer

$invpitable public_oe property

Inverse key expansion randomization table.
See also: self::setKey()
public array $invpitable
return array

$key public_oe property

The Key
See also: phpseclib\Crypt\Common\SymmetricKey::key
See also: self::setKey()
public string $key
return string

$key_length public_oe property

Key Length (in bytes)
See also: phpseclib\Crypt\RC2::setKeyLength()
public int $key_length
return integer

$keys public_oe property

The Key Schedule
See also: self::_setupKey()
public array $keys
return array

$orig_key public_oe property

The Original (unpadded) Key
See also: phpseclib\Crypt\Common\SymmetricKey::key
See also: self::setKey()
See also: self::encrypt()
See also: self::decrypt()
public string $orig_key
return string

$pitable public_oe property

Twice the same 256-value sequence to save a modulus in key expansion.
See also: self::setKey()
public array $pitable
return array

$skip_key_adjustment public_oe property

Don't truncate / null pad key
See also: phpseclib\Crypt\Common\SymmetricKey::_clearBuffers()
public bool $skip_key_adjustment
return boolean