@@ 333-342 (lines=10) @@ | ||
330 | $hash = hex2bin(md5(self::ENCRYPTION_PADDING . $idEntry)); |
|
331 | $value = self::applyRc4Loop(openssl_encrypt($hash, 'rc4', $key), $key, $keyLength); |
|
332 | ||
333 | if (function_exists('random_bytes')) { |
|
334 | // As of PHP 7 |
|
335 | $value .= random_bytes(16); |
|
336 | } else { |
|
337 | mt_srand(); |
|
338 | ||
339 | for ($i = 0; $i < 16; ++$i) { |
|
340 | $value .= chr(mt_rand(0, 255)); |
|
341 | } |
|
342 | } |
|
343 | ||
344 | return [ |
|
345 | $value, |
@@ 19-29 (lines=11) @@ | ||
16 | */ |
|
17 | public function encrypt($plaintext, $objectNumber, $generationNumber) |
|
18 | { |
|
19 | if (function_exists('random_bytes')) { |
|
20 | // As of PHP 7 |
|
21 | $initializationVector = random_bytes(16); |
|
22 | } else { |
|
23 | $initializationVector = ''; |
|
24 | mt_srand(); |
|
25 | ||
26 | for ($i = 0; $i < 16; ++$i) { |
|
27 | $initializationVector .= chr(mt_rand(0, 255)); |
|
28 | } |
|
29 | } |
|
30 | ||
31 | return $initializationVector . openssl_encrypt( |
|
32 | $plaintext, |