Files
TwoFactorAuth/lib/Providers/Rng/OpenSSLRNGProvider.php
T
Nicolas CARPi aeb4b00c60 first batch
2022-12-07 22:28:52 +01:00

28 lines
548 B
PHP

<?php
namespace RobThree\Auth\Providers\Rng;
class OpenSSLRNGProvider implements IRNGProvider
{
public function __construct(private bool $requirestrong = true)
{
}
/**
* {@inheritdoc}
*/
public function getRandomBytes(int $bytecount): string
{
// will throw an Exception on failure
return openssl_random_pseudo_bytes($bytecount, $crypto_strong);
}
/**
* {@inheritdoc}
*/
public function isCryptographicallySecure(): bool
{
return $this->requirestrong;
}
}