| 1 | <?php |
||
| 12 | class OpenSslGenerator implements Generator |
||
| 13 | { |
||
| 14 | |||
| 15 | /** |
||
| 16 | * Length of the desired string of bytes |
||
| 17 | * |
||
| 18 | * @var int |
||
| 19 | */ |
||
| 20 | protected $bytes = PHP_INT_SIZE; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * Force strong random number generation or "die" |
||
| 24 | * |
||
| 25 | * @var bool |
||
| 26 | */ |
||
| 27 | protected $forceStrong = true; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Constructor |
||
| 31 | * |
||
| 32 | * @param int $bytes Bytes to use in result |
||
| 33 | * @param int $forceStrong Force strong random number generation |
||
| 34 | */ |
||
| 35 | public function __construct($bytes = PHP_INT_SIZE, $forceStrong = true) |
||
| 40 | |||
| 41 | /** |
||
| 42 | * @inheritdoc |
||
| 43 | * @see http://php.net/manual/en/function.openssl-random-pseudo-bytes.php |
||
| 44 | * @throws \RuntimeException |
||
| 45 | */ |
||
| 46 | public function getRandomInt() |
||
| 57 | |||
| 58 | } |