mirror of
https://github.com/RobThree/TwoFactorAuth.git
synced 2026-08-24 14:36:34 +00:00
42 lines
732 B
PHP
42 lines
732 B
PHP
<?php
|
|
|
|
namespace Tests\Providers\Rng;
|
|
|
|
use RobThree\Auth\Providers\Rng\IRNGProvider;
|
|
|
|
class TestRNGProvider implements IRNGProvider
|
|
{
|
|
/** @var bool */
|
|
private $isSecure;
|
|
|
|
/**
|
|
* @param bool $isSecure whether this provider is cryptographically secure
|
|
*/
|
|
function __construct($isSecure = false)
|
|
{
|
|
$this->isSecure = $isSecure;
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function getRandomBytes($bytecount)
|
|
{
|
|
$result = '';
|
|
|
|
for ($i = 0; $i < $bytecount; $i++) {
|
|
$result .= chr($i);
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function isCryptographicallySecure()
|
|
{
|
|
return $this->isSecure;
|
|
}
|
|
}
|