add new function createNonce()

This commit is contained in:
Uwe Steinmann 2020-09-15 12:13:51 +02:00
parent 124c3c70a3
commit f0d5821bd1

View File

@ -632,6 +632,22 @@ function seed_pass_verify($password, $hash) { /* {{{ */
return $hash == md5($password);
} /* }}} */
/**
* Return nonce for CSP
*
* @return string
*/
function createNonce() { /* {{{ */
$length = 16;
$usable = true;
$bytes = openssl_random_pseudo_bytes($length, $usable);
if ($usable === false) {
// weak
// @TODO do something?
}
return base64_encode($bytes);
} /* }}} */
/**
* Class for creating encrypted api keys
*