Skip to main content

This is a collection of Django Model Field classes that are encrypted using PyNaCl.

Project description

Build Status Read the Docs (version)

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.

About PyNaCl

PyNaCl is a Python binding to libsodium, which is a fork of the Networking and Cryptography library. These libraries have a stated goal of improving usability, security and speed.

Getting Started

~ 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 = 'cGa9QJDY/FJhbITXHnrIqlgyeLDS04/WqWtgqPEIU4A='

In your settings.py (or append it automatically after generation using the -f flag)

NACL_FIELDS_KEY = 'cGa9QJDY/FJhbITXHnrIqlgyeLDS04/WqWtgqPEIU4A='

Then, in your models.py

from django.db import models
from fields import NaClTextField


class MyModel(models.Model):
        text_field = NaClTextField()

Use your model as normal and your data will be 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.

Available Fields

Currently build in and unit-tested fields.

  • NaClCharField

  • NaClTextField

  • NaClDateTimeField

  • NaClIntegerField

  • NaClFloatField

  • NaClEmailField

  • NaClBooleanField

Encrypt Your Own Fields

Making new fields can be done by using the build-in NaClFieldMixin:

from django.db import models
from fields import NaClFieldMixin

class EncryptedIPAddressField(NaClFieldMixin, models.IPAddressField):
        pass

Please report any issues you encounter when trying this.

References

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

django_nacl_fields-1.0.0.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

django_nacl_fields-1.0.0-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file django_nacl_fields-1.0.0.tar.gz.

File metadata

  • Download URL: django_nacl_fields-1.0.0.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.27.0 CPython/3.6.6

File hashes

Hashes for django_nacl_fields-1.0.0.tar.gz
Algorithm Hash digest
SHA256 bcae63e5fa014ddedef6823d1f9def39680310b41cf8afe340823a0eae5ff58f
MD5 0c2f84e1b130d3d5c2740346926b4fde
BLAKE2b-256 1c5e19b1c168c9909c004adefa70ad10d742bf8f332b2c754a2ed9309660014c

See more details on using hashes here.

File details

Details for the file django_nacl_fields-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: django_nacl_fields-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 12.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.27.0 CPython/3.6.6

File hashes

Hashes for django_nacl_fields-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aab38917c4a97eec702a7c0c8efe010cfbeea933720c3157511724f34339667a
MD5 08e6a5395a394b5152324649d6081ad8
BLAKE2b-256 0f96861286dbc3833e45afb617f699f6de66cf6791664381cf7de58231606182

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page