Fix encryption error when openssl is installed but mcrypt isn't

backport https://github.com/defuse/php-encryption/pull/40
see https://www.xetown.com/qna/588527
This commit is contained in:
Kijin Sung 2017-05-07 15:04:53 +09:00
parent 8b229b91aa
commit 865e34c0d0

4
vendor/defuse/php-encryption/Crypto.php vendored Executable file → Normal file
View file

@ -342,8 +342,8 @@ final class Crypto
*/
private static function SecureRandom($octets)
{
self::EnsureFunctionExists("mcrypt_create_iv");
$random = mcrypt_create_iv($octets, MCRYPT_DEV_URANDOM);
self::EnsureFunctionExists("openssl_random_pseudo_bytes");
$random = openssl_random_pseudo_bytes($octets);
if ($random === FALSE) {
throw new CannotPerformOperationException();
} else {