This is inspired by django-encrypted-fields.
Project description
Django Fernet Encrypted Fields
This package was created as a successor to django-encrypted-fields.
Getting Started
$ pip install django-fernet-encrypted-fields
In your settings.py
, set random SALT_KEY
SALT_KEY = '0123456789abcdefghijklmnopqrstuvwxyz'
Then, in models.py
from encrypted_fields.fields import EncryptedTextField
class MyModel(models.Model):
text_field = EncryptedTextField()
Use your model as normal and your data will be encrypted in the database.
Rotating SALT keys
You can rotate salt keys by turning the SALT_KEY
settings.py entry into a list. The first key will be used to encrypt all new data, and decryption of existing values will be attempted with all given keys in order. This is useful for key rotation: place a new key at the head of the list for use with all new or changed data, but existing values encrypted with old keys will still be accessible
SALT_KEY = [
'zyxwvutsrqponmlkjihgfedcba9876543210',
'0123456789abcdefghijklmnopqrstuvwxyz'
]
If you wish to update the existing encrypted records simply load and re-save the models to use the new key.
for obj in MuModel.objects.all():
obj.save()
Available Fields
Currently build in and unit-tested fields. They have the same APIs as their non-encrypted counterparts.
EncryptedCharField
EncryptedTextField
EncryptedDateTimeField
EncryptedIntegerField
EncryptedFloatField
EncryptedEmailField
EncryptedBooleanField
EncryptedJSONField
Compatible Django Version
Compatible Django Version | Specifically tested |
---|---|
2.2 |
:heavy_check_mark: |
3.0 |
:heavy_check_mark: |
3.1 |
:heavy_check_mark: |
3.2 |
:heavy_check_mark: |
4.0 |
:heavy_check_mark: |
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django-fernet-encrypted-fields-0.1.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8cd10033f0ba153d94f3245551e5beb1b90a149d90e69d98b4581bc65db23b7a |
|
MD5 | 6db7e806db56cac437c34cab5a052be1 |
|
BLAKE2b-256 | d5b9d5fec53d65603132f31c24cb5ed2d02c7a86f566dcaaa32e0e907f1d3fd3 |
Hashes for django_fernet_encrypted_fields-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 981be25b42d75dec502c71ddf93f15385ab56d18e0829867fb2ba717ae4dc216 |
|
MD5 | 53e1e3ffd13c4502f0583aeed7ffea83 |
|
BLAKE2b-256 | 9dfe6d29fce5e0cdc249190175c0c2e4844735b9bb2bfe832f235f129fee367c |