Futuresony commited on
Commit
e99119f
·
verified ·
1 Parent(s): 4aa0c70

Create api_generation.py

Browse files
Files changed (1) hide show
  1. api_generation.py +17 -0
api_generation.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import secrets
2
+ import string
3
+
4
+ def generate_api_key(length=32):
5
+ """Generate a random, URL-safe text string starting with 'fs_'."""
6
+ # Generate a random string of the desired length minus the prefix length
7
+ random_part_length = length - 3 # 'fs_' is 3 characters
8
+ if random_part_length < 0:
9
+ raise ValueError("Length must be at least 3 to include the 'fs_' prefix.")
10
+ alphabet = string.ascii_letters + string.digits
11
+ random_string = ''.join(secrets.choice(alphabet) for i in range(random_part_length))
12
+ return "fs_" + random_string
13
+
14
+ # Generate an API key with a length of 40 (including the 'fs_' prefix)
15
+ api_key = generate_api_key(40)
16
+ print("Generated API Key:")
17
+ print(api_key)