Skip to content

Commit

Permalink
Fixed a couple of spots where random values were not using cryptograp…
Browse files Browse the repository at this point in the history
…hically-secure methods.
  • Loading branch information
ziebelje committed Jan 8, 2022
1 parent ee6a196 commit 14bed9c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion api/cora/session.php
Expand Up @@ -250,7 +250,7 @@ public function get() {
* @return string The generated session key.
*/
private function generate_session_key() {
return strtolower(sha1(uniqid(mt_rand(), true)));
return bin2hex(random_bytes(20));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions api/user.php
Expand Up @@ -55,8 +55,8 @@ public function create($attributes) {
* without having to spend the time creating an actual user.
*/
public function create_anonymous_user() {
$username = strtolower(sha1(uniqid(mt_rand(), true)));
$password = strtolower(sha1(uniqid(mt_rand(), true)));
$username = bin2hex(random_bytes(20));
$password = bin2hex(random_bytes(20));
$user = $this->create([
'username' => $username,
'password' => $password,
Expand Down

0 comments on commit 14bed9c

Please sign in to comment.