PHP Класс phpseclib\Crypt\TripleDES

Автор: Jim Wigginton ([email protected])
Наследование: extends phpseclib\Crypt\DES
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$cfb_init_len integer Optimizing value while CFB-encrypting
$cipher_name_mcrypt string The mcrypt specific name of the cipher
$des array Used only if $mode_3cbc === true
$key_length integer Key Length (in bytes)
$key_length_max string max possible size of $key
$mode_3cbc boolean Internal flag whether using self::MODE_3CBC or not
$password_default_salt string The default salt used by setPassword()

Открытые методы

Метод Описание
__construct ( integer $mode ) Default Constructor.
_setupKey ( ) Creates the key schedule
decrypt ( string $ciphertext ) : string Decrypts a message.
disableContinuousBuffer ( ) Treat consecutive packets as if they are a discontinuous buffer.
enableContinuousBuffer ( ) Treat consecutive "packets" as if they are a continuous buffer.
encrypt ( string $plaintext ) : string Encrypts a message.
isValidEngine ( integer $engine ) : boolean Test for engine validity
setIV ( string $iv ) Sets the initialization vector.
setKey ( string $key ) Sets the key.
setKeyLength ( integer $length ) Sets the key length.
setPreferredEngine ( integer $engine ) : integer Sets the internal crypt engine

Описание методов

__construct() публичный Метод

Determines whether or not the mcrypt or OpenSSL extensions should be used. $mode could be: - \phpseclib\Crypt\Common\BlockCipher::MODE_ECB - \phpseclib\Crypt\Common\BlockCipher::MODE_CBC - \phpseclib\Crypt\Common\BlockCipher::MODE_CTR - \phpseclib\Crypt\Common\BlockCipher::MODE_CFB - \phpseclib\Crypt\Common\BlockCipher::MODE_OFB - \phpseclib\Crypt\TripleDES::MODE_3CB
См. также: phpseclib\Crypt\DES::__construct()
См. также: phpseclib\Crypt\Common\SymmetricKey::__construct()
public __construct ( integer $mode )
$mode integer

_setupKey() публичный Метод

Creates the key schedule
См. также: phpseclib\Crypt\DES::_setupKey()
См. также: phpseclib\Crypt\Common\SymmetricKey::_setupKey()
public _setupKey ( )

decrypt() публичный Метод

Decrypts a message.
См. также: phpseclib\Crypt\Common\SymmetricKey::decrypt()
public decrypt ( string $ciphertext ) : string
$ciphertext string
Результат string $plaintext

disableContinuousBuffer() публичный Метод

The default behavior.
См. также: phpseclib\Crypt\Common\SymmetricKey::disableContinuousBuffer()
См. также: self::enableContinuousBuffer()

enableContinuousBuffer() публичный Метод

Say you have a 16-byte plaintext $plaintext. Using the default behavior, the two following code snippets will yield different outputs: echo $des->encrypt(substr($plaintext, 0, 8)); echo $des->encrypt(substr($plaintext, 8, 8)); echo $des->encrypt($plaintext); The solution is to enable the continuous buffer. Although this will resolve the above discrepancy, it creates another, as demonstrated with the following: $des->encrypt(substr($plaintext, 0, 8)); echo $des->decrypt($des->encrypt(substr($plaintext, 8, 8))); echo $des->decrypt($des->encrypt(substr($plaintext, 8, 8))); With the continuous buffer disabled, these would yield the same output. With it enabled, they yield different outputs. The reason is due to the fact that the initialization vector's change after every encryption / decryption round when the continuous buffer is enabled. When it's disabled, they remain constant. Put another way, when the continuous buffer is enabled, the state of the \phpseclib\Crypt\DES() object changes after each encryption / decryption round, whereas otherwise, it'd remain constant. For this reason, it's recommended that continuous buffers not be used. They do offer better security and are, in fact, sometimes required (SSH uses them), however, they are also less intuitive and more likely to cause you problems.
См. также: phpseclib\Crypt\Common\SymmetricKey::enableContinuousBuffer()
См. также: self::disableContinuousBuffer()

encrypt() публичный Метод

Encrypts a message.
См. также: phpseclib\Crypt\Common\SymmetricKey::encrypt()
public encrypt ( string $plaintext ) : string
$plaintext string
Результат string $cipertext

isValidEngine() публичный Метод

This is mainly just a wrapper to set things up for \phpseclib\Crypt\Common\SymmetricKey::isValidEngine()
См. также: phpseclib\Crypt\Common\SymmetricKey::__construct()
public isValidEngine ( integer $engine ) : boolean
$engine integer
Результат boolean

setIV() публичный Метод

SetIV is not required when \phpseclib\Crypt\Common\SymmetricKey::MODE_ECB is being used.
См. также: phpseclib\Crypt\Common\SymmetricKey::setIV()
public setIV ( string $iv )
$iv string

setKey() публичный Метод

Triple DES can use 128-bit (eg. strlen($key) == 16) or 192-bit (eg. strlen($key) == 24) keys. DES also requires that every eighth bit be a parity bit, however, we'll ignore that.
См. также: phpseclib\Crypt\DES::setKey()
См. также: phpseclib\Crypt\Common\SymmetricKey::setKey()
public setKey ( string $key )
$key string

setKeyLength() публичный Метод

Valid key lengths are 128 and 192 bits. If you want to use a 64-bit key use DES.php
public setKeyLength ( integer $length )
$length integer

setPreferredEngine() публичный Метод

Sets the internal crypt engine
См. также: phpseclib\Crypt\Common\SymmetricKey::__construct()
См. также: phpseclib\Crypt\Common\SymmetricKey::setPreferredEngine()
public setPreferredEngine ( integer $engine ) : integer
$engine integer
Результат integer

Описание свойств

$cfb_init_len публичное свойство

Optimizing value while CFB-encrypting
См. также: phpseclib\Crypt\Common\SymmetricKey::cfb_init_len
public int $cfb_init_len
Результат integer

$cipher_name_mcrypt публичное свойство

The mcrypt specific name of the cipher
См. также: phpseclib\Crypt\DES::cipher_name_mcrypt
См. также: phpseclib\Crypt\Common\SymmetricKey::cipher_name_mcrypt
public string $cipher_name_mcrypt
Результат string

$des публичное свойство

Used only if $mode_3cbc === true
public array $des
Результат array

$key_length публичное свойство

Key Length (in bytes)
См. также: phpseclib\Crypt\TripleDES::setKeyLength()
public int $key_length
Результат integer

$key_length_max публичное свойство

max possible size of $key
См. также: self::setKey()
См. также: phpseclib\Crypt\DES::setKey()
public string $key_length_max
Результат string

$mode_3cbc публичное свойство

Internal flag whether using self::MODE_3CBC or not
public bool $mode_3cbc
Результат boolean

$password_default_salt публичное свойство

The default salt used by setPassword()
См. также: phpseclib\Crypt\Common\SymmetricKey::password_default_salt
См. также: phpseclib\Crypt\Common\SymmetricKey::setPassword()
public string $password_default_salt
Результат string