mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2026-07-27 13:40:12 +02:00
25 lines
793 B
PHP
25 lines
793 B
PHP
<?php
|
|
|
|
namespace RobThree\Auth\Providers\Rng;
|
|
|
|
class OpenSSLRNGProvider implements IRNGProvider
|
|
{
|
|
private $requirestrong;
|
|
|
|
function __construct($requirestrong = true) {
|
|
$this->requirestrong = $requirestrong;
|
|
}
|
|
|
|
public function getRandomBytes($bytecount) {
|
|
$result = openssl_random_pseudo_bytes($bytecount, $crypto_strong);
|
|
if ($this->requirestrong && ($crypto_strong === false))
|
|
throw new \RNGException('openssl_random_pseudo_bytes returned non-cryptographically strong value');
|
|
if ($result === false)
|
|
throw new \RNGException('openssl_random_pseudo_bytes returned an invalid value');
|
|
return $result;
|
|
}
|
|
|
|
public function isCryptographicallySecure() {
|
|
return $this->requirestrong;
|
|
}
|
|
} |