7 declare(strict_types=1);
48 string $cipher = MCRYPT_BLOWFISH,
49 string $mode = MCRYPT_MODE_ECB,
50 string $initVector =
null 52 $this->cipher = $cipher;
55 $this->handle = @mcrypt_module_open($cipher,
'', $mode,
'');
58 $maxKeySize = @mcrypt_enc_get_key_size($this->handle);
59 if (strlen($key) > $maxKeySize) {
60 throw new \Magento\Framework\Exception\LocalizedException(
61 new \
Magento\Framework\
Phrase(
'Key must not exceed %1 bytes.', [$maxKeySize])
66 if (
null === $initVector) {
70 throw new \Magento\Framework\Exception\LocalizedException(
72 'Init vector must be a string of %1 bytes.',
77 $this->initVector = $initVector;
78 }
catch (\Exception $e) {
80 @mcrypt_module_close($this->handle);
81 throw new \Magento\Framework\Exception\LocalizedException(
new \
Magento\Framework\
Phrase($e->getMessage()));
84 @mcrypt_generic_init($this->handle, $key, $initVector);
93 @mcrypt_generic_deinit($this->handle);
94 @mcrypt_module_close($this->handle);
105 return $this->cipher;
125 return $this->initVector;
135 return $this->handle;
147 if (strlen(
$data) == 0) {
151 return @mcrypt_generic($this->
getHandle(), $data);
162 if (strlen(
$data) == 0) {
166 $data = @mdecrypt_generic($this->handle,
$data);
elseif(isset( $params[ 'redirect_parent']))
__construct(string $key, string $cipher=MCRYPT_BLOWFISH, string $mode=MCRYPT_MODE_ECB, string $initVector=null)