From 20c4ca798590881f78bf164ef26a3068b87f2ab7 Mon Sep 17 00:00:00 2001 From: Jakub Onderka Date: Sat, 19 Feb 2022 11:16:03 +0100 Subject: [PATCH] chg: [cli] Use more entropy when generating new encryption key --- app/Console/Command/AdminShell.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/Console/Command/AdminShell.php b/app/Console/Command/AdminShell.php index e38b26e3f..e009eded8 100644 --- a/app/Console/Command/AdminShell.php +++ b/app/Console/Command/AdminShell.php @@ -936,7 +936,7 @@ class AdminShell extends AppShell $new = $this->params['new'] ?? null; if ($new !== null && strlen($new) < 32) { - $this->error('New key must be at least 32 char long.'); + $this->error('New key must be at least 32 chars long.'); } if ($old === null) { @@ -945,8 +945,7 @@ class AdminShell extends AppShell if ($new === null) { // Generate random new key - $randomTool = new RandomTool(); - $new = $randomTool->random_str(); + $new = rtrim(base64_encode(random_bytes(32)), "="); } $this->Server->getDataSource()->begin();