Symmetric encryption for model fields in Django
Project description
Django Symmetric Fields
This package provides encrypted model fields in Django using symmetric fernet encryption.
Getting started
Package installation
$ pip install django-symmetric-fields
Keys
django-symmetric-fields
uses fernet keys from settings.py
for encryption. Provide a list of keys in the DSF_ENCRYPTION_KEYS
setting. E.g:
DSF_ENCRYPTION_KEYS = [
b"key1",
b"key2",
]
Package supports key rotation. A newest key in the front of the list is used to encrypt new data, while the later ones assure that the old encrypted data can still be read.
Usage
After you've completed the initial installation and provided keys in settings.py
you can import your new fernet fields like any other:
from symmetricfields.fields import FernetEncryptedTextField
class ModelWithEncryptedField(models.Model):
encrypted_field = FernetEncryptedTextField()
Retrieving values
Each field is provided with two properties used to retrieve the values of the fields value
and decrypted
. The values are not decrypted until explicitly requested.
ModelWithEncryptedField.objects.create(encrypted_field='test')
my_new_encrypted_object = ModuleWithEncryptedField.objects.first()
my_new_encrypted_object.encrypted_field.value # returns encrypted value of the field
my_new_encrypted_object.encrypted_field.decrypted # returns 'test'
Supports
python >= 3.7, django>=2.0
requires cryptography >= 0.9
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-symmetric-fields-0.0.6.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2c4cc7fd63a5843427bd2877f62a054f653a6279c7bfc3f8c57e08a549f9dd7 |
|
MD5 | 6439f26a2a67e7fc74e450addd7a3425 |
|
BLAKE2b-256 | 6880072fded651a660cb2fff3ba0a353288208047642dcea474181174fa18d97 |
Hashes for django_symmetric_fields-0.0.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c877f8e8fb518c7ead056eb4074b9fa79175ba83dbe2b477504ea29ca7d1bef |
|
MD5 | d15690345b1446fed383275dddfdbddc |
|
BLAKE2b-256 | 5d93fd654e44d3130e4789070cfd7cbb609f50887c5be66e1057a0546727b57e |