1 parent 6b959a3 commit 644be13Copy full SHA for 644be13
1 file changed
app/utils.py
@@ -1,5 +1,5 @@
1
-import random
2
import re
+import secrets
3
import string
4
from urllib.parse import urlsplit, urlunsplit
5
@@ -11,7 +11,7 @@
11
12
def generate_short_code(length: int = SHORT_CODE_LENGTH) -> str:
13
chars = string.ascii_letters + string.digits
14
- return "".join(random.choices(chars, k=length))
+ return "".join(secrets.choice(chars) for _ in range(length))
15
16
def validate_url(url: str) -> bool:
17
if len(url) > MAX_URL_LENGTH:
0 commit comments