This is a collection of Django Model Field classes that are encrypted using PyNaCl.
Django NaCl Encrypted Fields
This is a collection of Django Model Field classes that are encrypted using PyNaCl. This package is largely based on django-encrypted-fields, which makes use of the outdated Keyczar library to encrypt fields. Besides that, it is inspired by django-fernet-field.
pip install django-nacl-fields
Create a key to be used for encryption:
$ python manage.py createkey # put the following line in your settings.py: NACL_FIELDS_KEY = b'p1Et2Rb@;^BYdo`ZRFi!Hc-MXu(^|bVqA-FGqffM'
NACL_FIELDS_KEY = b'p1Et2Rb@;^BYdo`ZRFi!Hc-MXu(^|bVqA-FGqffM'
Then, in your
from django.db import models from nacl_encrypted_fields import NaClTextField class MyModel(models.Model): text_field = NaClTextField()
Use the model as you would normally and the data will be stored encrypted in the database.
Note: Encrypted data cannot be used to query or sort. In SQL, these will all look like text fields with random text.
It is also possible to append the fields key to your settings file automatically upon creation, by using the
python manage.py createkey -f settings.py
settings.py is the path to your settings file.
Currently build-in and unit-tested fields.
Encrypt Your Own Fields
Making new fields can be done by using the provided
from django.db import models from nacl_encrypted_fields import NaClFieldMixin class NaClIPAddressField(NaClFieldMixin, models.IPAddressField): pass
Please report any issues you encounter when trying this.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size django_nacl_fields-4.0.0-py3-none-any.whl (12.5 kB)||File type Wheel||Python version py3||Upload date||Hashes View|
|Filename, size django-nacl-fields-4.0.0.tar.gz (14.2 kB)||File type Source||Python version None||Upload date||Hashes View|
Hashes for django_nacl_fields-4.0.0-py3-none-any.whl