From 8eb09cf9e194abfdb650b314514ec9442e9d599d Mon Sep 17 00:00:00 2001 From: link2xt Date: Tue, 7 Nov 2023 18:57:47 +0000 Subject: [PATCH] Use standard `secrets` module for password generation --- src/mailadm/util.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/mailadm/util.py b/src/mailadm/util.py index 88e718a1..6c34425d 100644 --- a/src/mailadm/util.py +++ b/src/mailadm/util.py @@ -1,12 +1,10 @@ -import base64 import random +import secrets import sys def gen_password(): - with open("/dev/urandom", "rb") as f: - s = f.read(21) - return base64.b64encode(s).decode("ascii")[:12] + return secrets.token_urlsafe(20) def get_human_readable_id(len=5, chars="2345789acdefghjkmnpqrstuvwxyz"):