mirror of
https://github.com/jazzband/django-fernet-encrypted-fields.git
synced 2026-03-16 22:40:27 +00:00
add snippet on generating SECRET_KEYs
This commit is contained in:
parent
e09d4ea7ff
commit
f005bc86f4
1 changed files with 9 additions and 0 deletions
|
|
@ -39,6 +39,15 @@ SALT_KEY = [
|
|||
]
|
||||
```
|
||||
|
||||
To generate a new `SECRET_KEY`, you can use Django's `get_random_secret_key` function.
|
||||
|
||||
```python
|
||||
from django.core.management.utils import get_random_secret_key
|
||||
|
||||
new_secret_key = get_random_secret_key()
|
||||
print(new_secret_key)
|
||||
```
|
||||
|
||||
#### Rotating SECRET_KEY
|
||||
|
||||
When you would want to rotate your `SECRET_KEY`, set the new value and put your old secret key value to `SECRET_KEY_FALLBACKS` list. That way the existing encrypted fields will still work, but when you re-save the field or create new record, it will be encrypted with the new secret key. (supported in Django >=4.1)
|
||||
|
|
|
|||
Loading…
Reference in a new issue