Глядя на KeyGenerator источник, вы можете переопределить свой KeyGenerator
класс.
class CustomKeyGenerator(KeyGenerator):
def get_prefix(self) -> str:
return 'your_prefix'
def get_secret_key(self) -> str:
return 'your_secret_key'
# Below, you can modify the way your "hasher" works,
# but I wouldn't play with that as it's native django's auth' hasher.
def hash(self, key: str) -> str:
#your hashing algorithm
return 'your_hashed_key'
def verify(self, key: str, hashed_key: str) -> bool:
#checking given key
return bool()
Затем в своем коде используйте CustomKeyGenerator
вместо KeyGenerator
Важное примечание: Вместо переопределения функций hash
и verify
, я бы порекомендовал вам настроить собственные требуемые PASSWORD_HASHERS