diff --git a/django_crypto_fields/field_cryptor.py b/django_crypto_fields/field_cryptor.py index 8b91857..cf8c8f8 100644 --- a/django_crypto_fields/field_cryptor.py +++ b/django_crypto_fields/field_cryptor.py @@ -2,6 +2,7 @@ from Cryptodome.Cipher import AES as AES_CIPHER from django.apps import apps as django_apps +from django.conf import settings from django.core.cache import cache from django.core.exceptions import ObjectDoesNotExist @@ -142,7 +143,14 @@ def using(self): def cache_key_prefix(self) -> bytes: algorithm = safe_encode_utf8(self.algorithm) access_mode = safe_encode_utf8(self.access_mode) - return b"django-crypto-fields-" + algorithm + b"-" + access_mode + b"-" + prefix = safe_encode_utf8( + getattr( + settings, + "CACHE_CRYPTO_KEY_PREFIX", + "crypto", + ) + ) + return prefix + algorithm + b"-" + access_mode + b"-" def update_crypt(self, cipher: Cipher) -> None: """Updates Crypt model and the cache. diff --git a/django_crypto_fields/tests/crypto_keys/django_crypto_fields b/django_crypto_fields/tests/crypto_keys/django_crypto_fields index bf0bfe5..d33aac3 100644 --- a/django_crypto_fields/tests/crypto_keys/django_crypto_fields +++ b/django_crypto_fields/tests/crypto_keys/django_crypto_fields @@ -1,2 +1,2 @@ path,date -/Users/erikvw/source/edc_source/django-crypto-fields/django_crypto_fields/tests/crypto_keys,2024-03-21 03:44:41.226908+00:00 +/Users/erikvw/source/edc_source/django-crypto-fields/django_crypto_fields/tests/crypto_keys,2024-03-25 06:53:16.697430+00:00