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
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
File details
Details for the file django-fernet-encrypted-fields-0.1.2.tar.gz
.
File metadata
- Download URL: django-fernet-encrypted-fields-0.1.2.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.8.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 068bf28b531c4353f705d4c6bf2c41bf0a1750322efec4cdc32db44e69311c45 |
|
MD5 | 958a4c5dd150137ef1b4a56e04b6be03 |
|
BLAKE2b-256 | 14227df13a7681905195a05239e09537ea5b2a9900bf9bc1918d746ef52b2a63 |
File details
Details for the file django_fernet_encrypted_fields-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: django_fernet_encrypted_fields-0.1.2-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.8.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cde96ddc7555acadfb1fe5145c0ac460c6e95d00064e8db7259daa5103a040fe |
|
MD5 | 04a99df956d1da89f2653a071a372fb9 |
|
BLAKE2b-256 | f949c93b69b3362a602556df8c01dbccff7e329187991b90d44eaded11f1d3da |