I'm building a testing application in Django that generates api key using the module Django RestFramework API Key. (Refer here: https://florimondmanca.github.io/djangorestframework-api-key/)
I want to include some symbols or hyphen in the middle of the generated key.
I have tried the default key generator in the module but I want to make it more secure.
#models.py
from rest_framework_api_key.models import BaseAPIKeyManager
from rest_framework_api_key.crypto import KeyGenerator
from rest_framework_api_key.models import AbstractAPIKey
class UserCompanyAPIKeyManager(BaseAPIKeyManager):
key_generator = KeyGenerator(prefix_length=32, secret_key_length=32)
class UserCompanyAPIKey(AbstractAPIKey):
objects = UserCompanyAPIKeyManager()
Output:
Prefix = jlxGg6bnRdjtrW3Xr6Q6yUMKWAuc0D2u