Git Product home page Git Product logo

django-fernet-encrypted-fields's Introduction

Build Status Pypi Package

Django Fernet Encrypted Fields

This package was created as a successor to django-encrypted-fields.

Getting Started

$ pip install django-fernet-encrypted-fields

In your settings.py, set random SALT_KEY

SALT_KEY = '0123456789abcdefghijklmnopqrstuvwxyz'

Then, in models.py

from encrypted_fields.fields import EncryptedTextField

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

Use your model as normal and your data will be encrypted in the database.

Rotating SALT keys

You can rotate salt keys by turning the SALT_KEY settings.py entry into a list. The first key will be used to encrypt all new data, and decryption of existing values will be attempted with all given keys in order. This is useful for key rotation: place a new key at the head of the list for use with all new or changed data, but existing values encrypted with old keys will still be accessible

SALT_KEY = [
    'zyxwvutsrqponmlkjihgfedcba9876543210',
    '0123456789abcdefghijklmnopqrstuvwxyz'
]

If you wish to update the existing encrypted records simply load and re-save the models to use the new key.

for obj in MuModel.objects.all():
    obj.save()

Available Fields

Currently build in and unit-tested fields. They have the same APIs as their non-encrypted counterparts.

  • EncryptedCharField
  • EncryptedTextField
  • EncryptedDateTimeField
  • EncryptedIntegerField
  • EncryptedFloatField
  • EncryptedEmailField
  • EncryptedBooleanField

Compatible Django Version

Compatible Django Version Specifically tested
2.2 ✔️
3.0 ✔️
3.1 ✔️
3.2 ✔️
4.0 ✔️

django-fernet-encrypted-fields's People

Contributors

frgmt avatar hendrikschneider avatar naohide avatar stevenmapes avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.