53 public function get($raw =
false) {
63 if ($this->key[0] ===
'z') {
65 $base64 = strtr(
substr($this->key, 1),
'-_',
'+/');
66 $key = base64_decode($base64);
76 return hex2bin($this->key);
88 $secret = $this->
get();
89 if ($secret[0] !==
'z') {
90 $rand_max = getrandmax();
91 if ($rand_max < pow(2, 16)) {
94 if ($rand_max < pow(2, 32)) {
115 $table->
set(self::CONFIG_KEY, $key);
117 return new self($key);
129 $key = $table->
get(self::CONFIG_KEY);
134 return new self($key);
145 $key = $config->{self::CONFIG_KEY};
150 return new self($key);
static fromDatabase(ConfigTable $table)
Create from config/storage.
Exception thrown if an error which can only be found on runtime occurs.
Manages a site-specific secret key, encoded as a 32 byte string "secret".
__construct($key)
Constructor.
get(string $name)
Gets a configuration value.
Updates the basic settings for the primary site object.
getStrength()
Get the strength of the site secret.
static regenerate(Crypto $crypto, ConfigTable $table)
Initialise the site secret (32 bytes: "z" to indicate format + 186-bit key in Base64 URL) and save to...
static fromConfig(ElggConfig $config)
Create from a config value.
Thrown when there is a major problem with the installation.
getRandomString($length, $chars=null)
Generate a random string of specified length.
set(string $name, $value)
Add or update a config setting.
Manipulates values in the dbprefix_config table.