From 9dfb95a524453f853093b46adf3514b77fc694d4 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Thu, 6 May 2021 14:45:59 +0100 Subject: [PATCH] Use secrets library to generate tokens --- app/utils/__init__.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/utils/__init__.py b/app/utils/__init__.py index 78261cb7..ed84ed4f 100644 --- a/app/utils/__init__.py +++ b/app/utils/__init__.py @@ -13,8 +13,8 @@ # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -import random -import string + +import secrets from .flask import * from .models import * @@ -45,5 +45,4 @@ def shouldReturnJson(): def randomString(n): - return ''.join(random.choice(string.ascii_lowercase + \ - string.ascii_uppercase + string.digits) for _ in range(n)) + return secrets.token_hex(int(n / 2))