File tree Expand file tree Collapse file tree 3 files changed +5
-12
lines changed
Expand file tree Collapse file tree 3 files changed +5
-12
lines changed Original file line number Diff line number Diff line change 1+ # v1.2.0, 2018-07-05
2+ * openssl_random_pseudo_bytes removed
3+
14# v1.1.0, 2018-04-05
25* PHP7 support added
36* Generate a new unique token with openssl_random_pseudo_bytes added
Original file line number Diff line number Diff line change 11# Token Component
2- ![ version] ( https://img.shields.io/badge/version-1.1 .0-brightgreen.svg?style=flat-square " Version ")
2+ ![ version] ( https://img.shields.io/badge/version-1.2 .0-brightgreen.svg?style=flat-square " Version ")
33[ ![ MIT License] ( https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square )] ( https://github.com/flextype-components/token/blob/master/LICENSE )
44
55The Token component generate and store a unique token which can be used to help prevent [ CSRF] ( http://wikipedia.org/wiki/Cross_Site_Request_Forgery ) attacks.
Original file line number Diff line number Diff line change @@ -47,17 +47,7 @@ public static function generate(bool $new = false) : string
4747 if ($ new === true OR ! $ token ) {
4848
4949 // Generate a new unique token
50- if (function_exists ('openssl_random_pseudo_bytes ' )) {
51-
52- // Generate a random pseudo bytes token if openssl_random_pseudo_bytes is available
53- // This is more secure than uniqid, because uniqid relies on microtime, which is predictable
54- $ token = base64_encode (openssl_random_pseudo_bytes (32 ));
55-
56- } else {
57-
58- // Otherwise, fall back to a hashed uniqid
59- $ token = sha1 (uniqid (null , true ));
60- }
50+ $ token = sha1 (uniqid (mt_rand (), true ));
6151
6252 // Store the new token
6353 Session::set (Token::$ token_name , $ token );
You can’t perform that action at this time.
0 commit comments