mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-07-11 06:12:16 +00:00
Development
- Added check in `CsrfToken` class to ensure that IV generation is strong and secure. - Minor optimisations mostly related to PHPDocs and PHPStorm code-inspection.
This commit is contained in:
@@ -10,6 +10,7 @@ class CsrfToken
|
||||
/**
|
||||
* Generate random identifier for CSRF token
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
* @return string
|
||||
*/
|
||||
public static function generateToken()
|
||||
@@ -18,7 +19,14 @@ class CsrfToken
|
||||
return bin2hex(random_bytes(32));
|
||||
}
|
||||
|
||||
return bin2hex(openssl_random_pseudo_bytes(32));
|
||||
$isSourceStrong = false;
|
||||
|
||||
$random = openssl_random_pseudo_bytes(32, $isSourceStrong);
|
||||
if ($isSourceStrong === false || $random === false) {
|
||||
throw new \RuntimeException('IV generation failed');
|
||||
}
|
||||
|
||||
return $random;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user