35 $this->datalist = $datalist;
41 private $test_secret =
'';
50 $this->test_secret = $secret;
66 if ($this->datalist->set(
'__site_secret__', $secret)) {
83 function get($raw =
false) {
84 if ($this->test_secret) {
85 $secret = $this->test_secret;
87 $secret = $this->datalist->get(
'__site_secret__');
90 $secret = $this->
init();
95 if ($secret[0] ===
'z') {
97 $base64 = strtr(substr($secret, 1),
'-_',
'+/');
98 $key = base64_decode($base64);
105 return hex2bin($secret);
122 $secret = $this->
get();
123 if ($secret[0] !==
'z') {
124 $rand_max = getrandmax();
125 if ($rand_max < pow(2, 16)) {
128 if ($rand_max < pow(2, 32)) {
__construct(Datalist $datalist)
Constructor.
setTestingSecret($secret)
Set a secret to be used in testing.
init()
Initialise the site secret (32 bytes: "z" to indicate format + 186-bit key in Base64 URL)...
getStrength()
Get the strength of the site secret.
_elgg_services(\Elgg\Di\ServiceProvider $services=null)
Get the global service provider.