From 87dfe5ea95b48f6fccac6e3a8b87e10e7fa5f697 Mon Sep 17 00:00:00 2001 From: Anna Larch Date: Wed, 29 Jun 2022 18:32:52 +0200 Subject: [PATCH] Shuffle before validating Signed-off-by: Anna Larch --- lib/Generator.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Generator.php b/lib/Generator.php index ca9ea63f..b578b848 100644 --- a/lib/Generator.php +++ b/lib/Generator.php @@ -85,6 +85,9 @@ public function generate(): string { $password .= $chars = $this->random->generate($length, $chars); + // Shuffle string so the order is random + $password = str_shuffle($password); + try { $this->validator->validate($password); @@ -108,9 +111,6 @@ public function generate(): string { throw new HintException('Could not generate a valid password'); } - // Shuffle string so the order is random - $password = str_shuffle($password); - return $password; } }