Skip to content

Commit 3e6e499

Browse files
committed
refactor(a2): refactor salt generation
1 parent 3d8a174 commit 3e6e499

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

a2/resources.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ function signup(&$request, &$response, &$db, &$pdo)
165165
$email = strtolower($email);
166166

167167
// Hash password with salt
168-
$salt = md5(rand()) . md5(rand());
168+
$salt = md5(uniqid(rand())) . md5(uniqid(rand()));
169169
$password = hash('sha256', $password .= $salt);
170170

171171
// generate timestamp
@@ -214,7 +214,7 @@ function identify(&$request, &$response, &$db, &$pdo)
214214
log_to_console("Used existing challenge!");
215215
} else {
216216
// Generate new challenge, update expires
217-
$challenge = md5(rand()) . md5(rand());
217+
$challenge = md5(uniqid(rand())) . md5(uniqid(rand()));
218218
$expires = new DateTime("+2 minutes");
219219
$expires = $expires->format(DateTimeInterface::ISO8601);
220220

0 commit comments

Comments
 (0)