Threatthriver commited on
Commit
79c5900
1 Parent(s): 6134731

Delete api.py

Browse files
Files changed (1) hide show
  1. api.py +0 -33
api.py DELETED
@@ -1,33 +0,0 @@
1
- import secrets
2
- import json
3
- import os
4
-
5
- API_KEYS_FILE = 'api_keys.json'
6
-
7
- def generate_api_key():
8
- """Generate a secure random API key."""
9
- return secrets.token_hex(32)
10
-
11
- def save_api_key(user_id, api_key):
12
- """Save the API key associated with a user."""
13
- if os.path.exists(API_KEYS_FILE):
14
- with open(API_KEYS_FILE, 'r') as f:
15
- api_keys = json.load(f)
16
- else:
17
- api_keys = {}
18
-
19
- api_keys[user_id] = api_key
20
-
21
- with open(API_KEYS_FILE, 'w') as f:
22
- json.dump(api_keys, f)
23
-
24
- def generate_and_save_api_keys(num_keys=15):
25
- """Generate and save a specified number of API keys."""
26
- for i in range(1, num_keys + 1):
27
- user_id = f"user_{i}"
28
- api_key = generate_api_key()
29
- save_api_key(user_id, api_key)
30
- print(f"API Key for {user_id}: {api_key}")
31
-
32
- if __name__ == "__main__":
33
- generate_and_save_api_keys(15)