summaryrefslogtreecommitdiffstats
path: root/g4f/providers
diff options
context:
space:
mode:
authorHeiner Lohaus <hlohaus@users.noreply.github.com>2024-03-12 18:45:22 +0100
committerHeiner Lohaus <hlohaus@users.noreply.github.com>2024-03-12 18:45:22 +0100
commit5bcf21f9bd2dd9ea581e5301113facda6fc28426 (patch)
treeee3bd34f1e061c80576d8a34cb2bf0033f80a4ac /g4f/providers
parentFix unit test with missing requirements (diff)
downloadgpt4free-5bcf21f9bd2dd9ea581e5301113facda6fc28426.tar
gpt4free-5bcf21f9bd2dd9ea581e5301113facda6fc28426.tar.gz
gpt4free-5bcf21f9bd2dd9ea581e5301113facda6fc28426.tar.bz2
gpt4free-5bcf21f9bd2dd9ea581e5301113facda6fc28426.tar.lz
gpt4free-5bcf21f9bd2dd9ea581e5301113facda6fc28426.tar.xz
gpt4free-5bcf21f9bd2dd9ea581e5301113facda6fc28426.tar.zst
gpt4free-5bcf21f9bd2dd9ea581e5301113facda6fc28426.zip
Diffstat (limited to 'g4f/providers')
-rw-r--r--g4f/providers/helper.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/g4f/providers/helper.py b/g4f/providers/helper.py
index df6767a4..5f3b4fb6 100644
--- a/g4f/providers/helper.py
+++ b/g4f/providers/helper.py
@@ -1,7 +1,6 @@
from __future__ import annotations
import random
-import secrets
import string
from ..typing import Messages
@@ -40,11 +39,14 @@ def get_random_string(length: int = 10) -> str:
for _ in range(length)
)
-def get_random_hex() -> str:
+def get_random_hex(length: int = 32) -> str:
"""
- Generate a random hexadecimal string of a fixed length.
+ Generate a random hexadecimal string with n length.
Returns:
- str: A random hexadecimal string of 32 characters (16 bytes).
+ str: A random hexadecimal string of n characters.
"""
- return secrets.token_hex(16).zfill(32) \ No newline at end of file
+ return ''.join(
+ random.choice("abcdef" + string.digits)
+ for _ in range(length)
+ ) \ No newline at end of file