Definition at line 38 of file Mcrypt.php.
◆ __construct()
Class constructor
- Parameters
-
Definition at line 74 of file Mcrypt.php.
76 if (!extension_loaded(
'mcrypt')) {
77 #require_once 'Zend/Filter/Exception.php'; 86 #require_once 'Zend/Filter/Exception.php'; 90 if (array_key_exists(
'compression',
$options)) {
elseif(isset( $params[ 'redirect_parent']))
setCompression($compression)
◆ _closeCipher()
◆ _initCipher()
Initialises the cipher with the set key
- Parameters
-
- Exceptions
-
Definition at line 328 of file Mcrypt.php.
330 $key = $this->_encryption[
'key'];
332 $keysizes = mcrypt_enc_get_supported_key_sizes($cipher);
333 if (empty($keysizes) || ($this->_encryption[
'salt'] ==
true)) {
335 $keysize = mcrypt_enc_get_key_size($cipher);
336 $key = substr(md5($key), 0, $keysize);
337 }
else if (!in_array(strlen($key), $keysizes)) {
338 #require_once 'Zend/Filter/Exception.php'; 342 $result = mcrypt_generic_init($cipher, $key, $this->_encryption[
'vector']);
344 #require_once 'Zend/Filter/Exception.php';
◆ _openCipher()
Open a cipher
- Exceptions
-
- Returns
- resource Returns the opened cipher
Definition at line 292 of file Mcrypt.php.
294 $cipher = mcrypt_module_open(
295 $this->_encryption[
'algorithm'],
296 $this->_encryption[
'algorithm_directory'],
297 $this->_encryption[
'mode'],
298 $this->_encryption[
'mode_directory']);
300 if ($cipher ===
false) {
301 #require_once 'Zend/Filter/Exception.php';
◆ _srand()
_srand() interception
- See also
- ZF-8742
Definition at line 356 of file Mcrypt.php.
358 if (version_compare(PHP_VERSION,
'5.3.0',
'>=')) {
361 if (!self::$_srandCalled) {
363 self::$_srandCalled =
true;
static randInteger($min, $max, $strong=false)
◆ decrypt()
Defined by Zend_Filter_Interface
Decrypts $value with the defined settings
- Parameters
-
string | $value | Content to decrypt |
- Returns
- string The decrypted content
Implements Zend_Filter_Encrypt_Interface.
Definition at line 258 of file Mcrypt.php.
262 $decrypted = mdecrypt_generic($cipher,
$value);
263 mcrypt_generic_deinit($cipher);
267 if (!empty($this->_compression)) {
268 #require_once 'Zend/Filter/Decompress.php'; 270 $decrypted = $decompress->filter($decrypted);
◆ encrypt()
Defined by Zend_Filter_Interface
Encrypts $value with the defined settings
- Parameters
-
string | $value | The content to encrypt |
- Returns
- string The encrypted content
Implements Zend_Filter_Encrypt_Interface.
Definition at line 232 of file Mcrypt.php.
235 if (!empty($this->_compression)) {
236 #require_once 'Zend/Filter/Compress.php'; 243 $encrypted = mcrypt_generic($cipher,
$value);
244 mcrypt_generic_deinit($cipher);
◆ getCompression()
Returns the compression
- Returns
- array
Definition at line 203 of file Mcrypt.php.
◆ getEncryption()
Returns the set encryption options
- Returns
- array
Definition at line 103 of file Mcrypt.php.
◆ getVector()
Returns the set vector
- Returns
- string
Definition at line 158 of file Mcrypt.php.
160 return $this->_encryption[
'vector'];
◆ setCompression()
setCompression |
( |
|
$compression | ) |
|
Sets a internal compression for values to encrypt
- Parameters
-
string | array | $compression | |
- Returns
- Zend_Filter_Encrypt_Mcrypt
Definition at line 214 of file Mcrypt.php.
216 if (is_string($this->_compression)) {
217 $compression = array(
'adapter' => $compression);
220 $this->_compression = $compression;
◆ setEncryption()
setEncryption |
( |
|
$options | ) |
|
Sets new encryption options
- Parameters
-
string | array | $options | Encryption options |
- Returns
- Zend_Filter_File_Encryption
Definition at line 114 of file Mcrypt.php.
121 #require_once 'Zend/Filter/Exception.php'; 126 $algorithms = mcrypt_list_algorithms(
$options[
'algorithm_directory']);
127 if (!in_array(
$options[
'algorithm'], $algorithms)) {
128 #require_once 'Zend/Filter/Exception.php'; 132 $modes = mcrypt_list_modes(
$options[
'mode_directory']);
133 if (!in_array(
$options[
'mode'], $modes)) {
134 #require_once 'Zend/Filter/Exception.php'; 138 if (!mcrypt_module_self_test(
$options[
'algorithm'],
$options[
'algorithm_directory'])) {
139 #require_once 'Zend/Filter/Exception.php'; 140 throw new Zend_Filter_Exception(
'The given algorithm can not be used due an internal mcrypt problem');
◆ setVector()
setVector |
( |
|
$vector = null | ) |
|
Sets the initialization vector
- Parameters
-
string | $vector | (Optional) Vector to set |
- Returns
- Zend_Filter_Encrypt_Mcrypt
Definition at line 169 of file Mcrypt.php.
172 $size = mcrypt_enc_get_iv_size($cipher);
173 if (empty($vector)) {
175 if (strtoupper(substr(PHP_OS, 0, 3)) ===
'WIN' && version_compare(PHP_VERSION,
'5.3.0',
'<')) {
178 if (file_exists(
'/dev/urandom') || (strtoupper(substr(PHP_OS, 0, 3)) ===
'WIN')) {
180 }
elseif (file_exists(
'/dev/random')) {
186 $vector = mcrypt_create_iv($size,
$method);
187 }
else if (strlen($vector) != $size) {
188 #require_once 'Zend/Filter/Exception.php'; 192 $this->_encryption[
'vector'] = $vector;
elseif(isset( $params[ 'redirect_parent']))
◆ toString()
Returns the adapter name
- Returns
- string
Definition at line 281 of file Mcrypt.php.
◆ $_compression
◆ $_encryption
Initial value:= array(
'key' => 'ZendFramework',
'algorithm' => 'blowfish',
'algorithm_directory' => '',
'mode' => 'cbc',
'mode_directory' => '',
'vector' => null,
'salt' => false
)
Definitions for encryption array( 'key' => encryption key string 'algorithm' => algorithm to use 'algorithm_directory' => directory where to find the algorithm 'mode' => encryption mode to use 'modedirectory' => directory where to find the mode )
Definition at line 50 of file Mcrypt.php.
◆ $_srandCalled
The documentation for this class was generated from the following file:
- vendor/magento/zendframework1/library/Zend/Filter/Encrypt/Mcrypt.php