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>=3.1
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django-symmetric-fields-0.0.9.tar.gz.
File metadata
- Download URL: django-symmetric-fields-0.0.9.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.13.0 keyring/23.13.1 rfc3986/2.0.0 colorama/0.4.3 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
259e005e82c5af606225709370cf79afde9738324e4aa0b4f1c4666f9de9e238
|
|
| MD5 |
1e3ef6d1301c5250d1b60c4952a34a7e
|
|
| BLAKE2b-256 |
8e11b6b6a1f5cf436873e38cb7a8425772ec2411be042a98387f28e57d42e153
|
File details
Details for the file django_symmetric_fields-0.0.9-py3-none-any.whl.
File metadata
- Download URL: django_symmetric_fields-0.0.9-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.13.0 keyring/23.13.1 rfc3986/2.0.0 colorama/0.4.3 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e18f248c0e093535366012584f27753a9d942f6e560aaeed9ff888c24454365d
|
|
| MD5 |
288ca3fed56e7ee7fe3217afe01a3095
|
|
| BLAKE2b-256 |
0f41e0922a69e5a590feb0d15b396835bdaa8bce9992f48bbb5eea9a44a1978a
|