From c4faa171e2cf42b3d7b18d31dc84085ef996a9de Mon Sep 17 00:00:00 2001 From: tchapi Date: Fri, 30 Aug 2024 22:58:07 +0200 Subject: [PATCH] Fix random bytes having null terminators --- src/Services/Utils.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Services/Utils.php b/src/Services/Utils.php index 07c6b80..cb7a73c 100644 --- a/src/Services/Utils.php +++ b/src/Services/Utils.php @@ -55,7 +55,7 @@ public function createPasswordlessUserWithDefaultObjects(string $username, strin $user->setUsername($username); // Set the password to a random string (but hashed beforehand) - $randomBytes = random_bytes(256); + $randomBytes = substr(bin2hex(random_bytes(256)), 0, 48); $hash = password_hash($randomBytes, PASSWORD_DEFAULT); $user->setPassword($hash);