Skip to content

Commit cd0d608

Browse files
committed
Replace single line codeStandardIgnore with codingStandardIgnoreLine
1 parent 347d3fd commit cd0d608

File tree

1 file changed

+8
-23
lines changed
  • lib/internal/Magento/Framework/Encryption/Adapter

1 file changed

+8
-23
lines changed

lib/internal/Magento/Framework/Encryption/Adapter/Mcrypt.php

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -45,29 +45,19 @@ public function __construct(
4545
) {
4646
$this->cipher = $cipher;
4747
$this->mode = $mode;
48-
// @codingStandardsIgnoreStart
48+
// @codingStandardIgnoreLine
4949
$this->handle = @mcrypt_module_open($cipher, '', $mode, '');
50-
// @codingStandardsIgnoreEnd
5150
try {
52-
// @codingStandardsIgnoreStart
51+
// @codingStandardIgnoreLine
5352
$maxKeySize = @mcrypt_enc_get_key_size($this->handle);
54-
// @codingStandardsIgnoreEnd
5553
if (strlen($key) > $maxKeySize) {
5654
throw new \Magento\Framework\Exception\LocalizedException(
5755
new \Magento\Framework\Phrase('Key must not exceed %1 bytes.', [$maxKeySize])
5856
);
5957
}
60-
// @codingStandardsIgnoreStart
58+
// @codingStandardIgnoreLine
6159
$initVectorSize = @mcrypt_enc_get_iv_size($this->handle);
62-
// @codingStandardsIgnoreEnd
63-
if (true === $initVector) {
64-
/* Generate a random vector from human-readable characters */
65-
$abc = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
66-
$initVector = '';
67-
for ($i = 0; $i < $initVectorSize; $i++) {
68-
$initVector .= $abc[rand(0, strlen($abc) - 1)];
69-
}
70-
} elseif (false === $initVector) {
60+
if (null === $initVector) {
7161
/* Set vector to zero bytes to not use it */
7262
$initVector = str_repeat("\0", $initVectorSize);
7363
} elseif (!is_string($initVector) || strlen($initVector) != $initVectorSize) {
@@ -80,14 +70,12 @@ public function __construct(
8070
}
8171
$this->_initVector = $initVector;
8272
} catch (\Exception $e) {
83-
// @codingStandardsIgnoreStart
73+
// @codingStandardIgnoreLine
8474
@mcrypt_module_close($this->handle);
85-
// @codingStandardsIgnoreEnd
86-
throw $e;
75+
throw new \Magento\Framework\Exception\LocalizedException(new \Magento\Framework\Phrase($e->getMessage()));
8776
}
88-
// @codingStandardsIgnoreStart
77+
// @codingStandardIgnoreLine
8978
@mcrypt_generic_init($this->handle, $key, $initVector);
90-
// @codingStandardsIgnoreEnd
9179
}
9280

9381
/**
@@ -97,8 +85,6 @@ public function __destruct()
9785
{
9886
// @codingStandardsIgnoreStart
9987
@mcrypt_generic_deinit($this->handle);
100-
// @codingStandardsIgnoreEnd
101-
// @codingStandardsIgnoreStart
10288
@mcrypt_module_close($this->handle);
10389
// @codingStandardsIgnoreEnd
10490
}
@@ -158,9 +144,8 @@ public function decrypt(string $data): string
158144
if (strlen($data) == 0) {
159145
return $data;
160146
}
161-
// @codingStandardsIgnoreStart
147+
// @codingStandardIgnoreLine
162148
$data = @mdecrypt_generic($this->handle, $data);
163-
// @codingStandardsIgnoreEnd
164149
/*
165150
* Returned string can in fact be longer than the unencrypted string due to the padding of the data
166151
* @link http://www.php.net/manual/en/function.mdecrypt-generic.php

0 commit comments

Comments
 (0)