mirror of
https://git.code.sf.net/p/seeddms/code
synced 2024-11-26 15:32:13 +00:00
add new function createNonce()
This commit is contained in:
parent
124c3c70a3
commit
f0d5821bd1
|
@ -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
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue
Block a user