PHP Class phpseclib\Crypt\RC4

Author: Jim Wigginton ([email protected])
Inheritance: extends phpseclib\Crypt\Base
Show file Open project: phpseclib/phpseclib Class Usage Examples

Public Properties

Property Type Description
$block_size integer RC4 is a stream cipher so we the block_size to 0
$cipher_name_mcrypt string The mcrypt specific name of the cipher
$key string The Key
$key_length integer Key Length (in bytes)
$stream array The Key Stream for decryption and encryption
$use_inline_crypt mixed Holds whether performance-optimized $inline_crypt() can/should be used.

Public Methods

Method Description
__construct ( ) : RC4 Default Constructor.
_crypt ( string $text, integer $mode ) : string Encrypts or decrypts a message.
_decryptBlock ( string $in ) Decrypts a block
_encryptBlock ( string $in ) Encrypts a block
_setupKey ( ) Setup the key (expansion)
decrypt ( string $ciphertext ) : string Decrypts a message.
encrypt ( string $plaintext ) : string Encrypts a message.
isValidEngine ( integer $engine ) : boolean Test for engine validity
setKey ( $key ) Sets the key length
setKeyLength ( integer $length ) Sets the key length
usesIV ( ) : boolean RC4 does not use an IV

Method Details

__construct() public method

Default Constructor.
See also: phpseclib\Crypt\Common\SymmetricKey::__construct()
public __construct ( ) : RC4
return RC4

_crypt() public method

Encrypts or decrypts a message.
See also: self::encrypt()
See also: self::decrypt()
public _crypt ( string $text, integer $mode ) : string
$text string
$mode integer
return string $text

_decryptBlock() public method

Decrypts a block
public _decryptBlock ( string $in )
$in string

_encryptBlock() public method

Encrypts a block
public _encryptBlock ( string $in )
$in string

_setupKey() public method

Setup the key (expansion)
See also: phpseclib\Crypt\Common\SymmetricKey::_setupKey()
public _setupKey ( )

decrypt() public method

$this->decrypt($this->encrypt($plaintext)) == $this->encrypt($this->encrypt($plaintext)). At least if the continuous buffer is disabled.
See also: phpseclib\Crypt\Common\SymmetricKey::encrypt()
See also: self::_crypt()
public decrypt ( string $ciphertext ) : string
$ciphertext string
return string $plaintext

encrypt() public method

Encrypts a message.
See also: phpseclib\Crypt\Common\SymmetricKey::decrypt()
See also: self::_crypt()
public encrypt ( string $plaintext ) : string
$plaintext string
return string $ciphertext

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 between 1 and 256 bytes long.
public setKey ( $key )

setKeyLength() public method

Keys can be between 1 and 256 bytes long.
public setKeyLength ( integer $length )
$length integer

usesIV() public method

RC4 does not use an IV
public usesIV ( ) : boolean
return boolean

Property Details

$block_size public property

RC4 is a stream cipher so we the block_size to 0
See also: phpseclib\Crypt\Common\SymmetricKey::block_size
public int $block_size
return integer

$cipher_name_mcrypt public property

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

$key public property

The Key
See also: self::setKey()
public string $key
return string

$key_length public property

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

$stream public property

The Key Stream for decryption and encryption
See also: self::setKey()
public array $stream
return array

$use_inline_crypt public property

Holds whether performance-optimized $inline_crypt() can/should be used.
See also: phpseclib\Crypt\Common\SymmetricKey::inline_crypt
public mixed $use_inline_crypt
return mixed