@@ 328-337 (lines=10) @@ | ||
325 | $hash = hex2bin(md5(self::ENCRYPTION_PADDING . $idEntry)); |
|
326 | $value = self::applyRc4Loop(openssl_encrypt($hash, 'rc4', $key), $key, $keyLength); |
|
327 | ||
328 | if (function_exists('random_bytes')) { |
|
329 | // As of PHP 7 |
|
330 | $value .= random_bytes(16); |
|
331 | } else { |
|
332 | mt_srand(); |
|
333 | ||
334 | for ($i = 0; $i < 16; ++$i) { |
|
335 | $value .= chr(mt_rand(0, 255)); |
|
336 | } |
|
337 | } |
|
338 | ||
339 | return [ |
|
340 | $value, |
@@ 53-63 (lines=11) @@ | ||
50 | */ |
|
51 | public function encrypt($plaintext, $objectNumber, $generationNumber) |
|
52 | { |
|
53 | if (function_exists('random_bytes')) { |
|
54 | // As of PHP 7 |
|
55 | $initializationVector = random_bytes(16); |
|
56 | } else { |
|
57 | $initializationVector = ''; |
|
58 | mt_srand(); |
|
59 | ||
60 | for ($i = 0; $i < 16; ++$i) { |
|
61 | $initializationVector .= chr(mt_rand(0, 255)); |
|
62 | } |
|
63 | } |
|
64 | ||
65 | return $initializationVector . openssl_encrypt( |
|
66 | $plaintext, |