Skip to content

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

License

Notifications You must be signed in to change notification settings

expobrain/django-encrypted-fields

Repository files navigation

Build Status

Django Encrypted Fields

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

About Keyczar

Keyczar is a crypto library that exposes a simple API by letting the user set things like the algorithm and key size right in the keyfile. It also provides for things like expiring old keys and cycling in new ones.

Getting Started

Create a basic keyczar keyset. AES-256 in this case.

$ mkdir fieldkeys
$ keyczart create --location=fieldkeys --purpose=crypt
$ keyczart addkey --location=fieldkeys --status=primary --size=256

In your settings.py

ENCRYPTED_FIELDS_KEYDIR = '/path/to/fieldkeys'

Then, in models.py

from encrypted_fields import (
    EncryptedCharField,
    EncryptedTextField,
    EncryptedDateTimeField,
    EncryptedIntegerField,
)

class MyModel(models.Model):
    char_field = EncryptedCharField(max_length=255)
    text_field = EncryptedTextField()
    datetime_field = EncryptedDateTimeField()
    integer_field = EncryptedIntegerField()

Available Fields

Currently, there are only 4 fields available. EncryptedCharField, EncryptedTextField, EncryptedDateTimeField, EncryptedIntegerField. They have the save APIs as their non-encrypted counterparts.

Encrypt All The Fields!

Making new fields is easy! Django Encrypted Fields uses a handy mixin to make upgrading pre-existing fields quite easy.

from django.db import models
from encrypted_fields import EncryptedFieldMixin

class EncryptedIPAddressField(EncryptedFieldMixin, models.IPAddressField):
    pass

Please report an issues you encounter when trying this, since I've only tested it with the 4 fields above.

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%