1 | <?php |
||
49 | class Sodium extends \RandomLib\AbstractSource |
||
50 | { |
||
51 | |||
52 | /** |
||
53 | * A property that may be forcibly set to `false` in the constructor, for |
||
54 | * the purpose of testing this source |
||
55 | * |
||
56 | * @var bool |
||
57 | */ |
||
58 | private $hasLibsodium = false; |
||
59 | |||
60 | /** |
||
61 | * Constructs a libsodium Random Number Source |
||
62 | * |
||
63 | * @param bool $useLibsodium May be set to `false` to disable libsodium for |
||
64 | * testing purposes |
||
65 | */ |
||
66 | public function __construct($useLibsodium = true) |
||
72 | |||
73 | /** |
||
74 | * If the source is currently available. |
||
75 | * Reasons might be because the library is not installed |
||
76 | * |
||
77 | * @return bool |
||
78 | */ |
||
79 | public static function isSupported() |
||
83 | |||
84 | /** |
||
85 | * Return an instance of Strength indicating the strength of the source |
||
86 | * |
||
87 | * @return Strength An instance of one of the strength classes |
||
88 | */ |
||
89 | public static function getStrength() |
||
93 | |||
94 | /** |
||
95 | * Generate a random string of the specified size |
||
96 | * |
||
97 | * @param int $size The size of the requested random string |
||
98 | * |
||
99 | * @return string A string of the requested size |
||
100 | */ |
||
101 | public function generate($size) |
||
109 | } |
||
110 |