mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
fix(fastapi): use secrets
module to generate random strings
Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
81f8c23265
commit
b0b5e4c9d1
1 changed files with 3 additions and 4 deletions
|
@ -1,7 +1,6 @@
|
||||||
import base64
|
import base64
|
||||||
import copy
|
import copy
|
||||||
import math
|
import math
|
||||||
import random
|
|
||||||
import re
|
import re
|
||||||
import secrets
|
import secrets
|
||||||
import string
|
import string
|
||||||
|
@ -25,9 +24,9 @@ from aurweb import defaults, logging
|
||||||
logger = logging.get_logger(__name__)
|
logger = logging.get_logger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def make_random_string(length):
|
def make_random_string(length: int) -> str:
|
||||||
return ''.join(random.choices(string.ascii_lowercase
|
alphanumerics = string.ascii_lowercase + string.digits
|
||||||
+ string.digits, k=length))
|
return ''.join([secrets.choice(alphanumerics) for i in range(length)])
|
||||||
|
|
||||||
|
|
||||||
def make_nonce(length: int = 8):
|
def make_nonce(length: int = 8):
|
||||||
|
|
Loading…
Add table
Reference in a new issue