1 | <?php |
||
14 | class OpenSslGenerator implements Generator |
||
15 | { |
||
16 | /** |
||
17 | * Length of the desired string of bytes |
||
18 | * |
||
19 | * @var int |
||
20 | */ |
||
21 | protected $bytes = PHP_INT_SIZE; |
||
22 | |||
23 | /** |
||
24 | * Force strong random number generation or "die" |
||
25 | * |
||
26 | * @var bool |
||
27 | */ |
||
28 | protected $forceStrong = true; |
||
29 | |||
30 | /** |
||
31 | * Constructor |
||
32 | * |
||
33 | * @param int $bytes Bytes to use in result |
||
34 | * @param bool $forceStrong Force strong random number generation |
||
35 | */ |
||
36 | 6 | public function __construct($bytes = PHP_INT_SIZE, $forceStrong = true) |
|
45 | |||
46 | /** |
||
47 | * @return bool |
||
48 | */ |
||
49 | 1 | public function isForceStrong(): bool |
|
53 | |||
54 | /** |
||
55 | * @inheritdoc |
||
56 | * @see https://php.net/manual/en/function.openssl-random-pseudo-bytes.php |
||
57 | * @throws RuntimeException |
||
58 | */ |
||
59 | 2 | public function getRandomInt() |
|
70 | } |
||
71 |