Skip to content

Commit

Permalink
Replaced SHA1 with random_bytes.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaellrowley committed Jul 24, 2021
1 parent 40a4380 commit ec15c33
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion application/model/PasswordResetModel.php
Expand Up @@ -37,7 +37,7 @@ public static function requestPasswordReset($user_name_or_email, $captcha)
// generate integer-timestamp (to see when exactly the user (or an attacker) requested the password reset mail)
// generate random hash for email password reset verification (40 char string)
$temporary_timestamp = time();
$user_password_reset_hash = sha1(uniqid(mt_rand(), true));
$user_password_reset_hash = random_bytes(40);

// set token (= a random hash string and a timestamp) into database ...
$token_set = self::setPasswordResetDatabaseToken($result->user_name, $user_password_reset_hash, $temporary_timestamp);
Expand Down
2 changes: 1 addition & 1 deletion application/model/RegistrationModel.php
Expand Up @@ -51,7 +51,7 @@ public static function registerNewUser()
if (!$return) return false;

// generate random hash for email verification (40 char string)
$user_activation_hash = sha1(uniqid(mt_rand(), true));
$user_activation_hash = random_bytes(40);

// write user data to database
if (!self::writeNewUserToDatabase($user_name, $user_password_hash, $user_email, time(), $user_activation_hash)) {
Expand Down

0 comments on commit ec15c33

Please sign in to comment.