Skip to main content

This is inspired by django-encrypted-fields.

Project description

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 :heavy_check_mark:
3.0 :heavy_check_mark:
3.1 :heavy_check_mark:
3.2 :heavy_check_mark:
4.0 :heavy_check_mark:

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-fernet-encrypted-fields-0.1.1.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file django-fernet-encrypted-fields-0.1.1.tar.gz.

File metadata

  • Download URL: django-fernet-encrypted-fields-0.1.1.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for django-fernet-encrypted-fields-0.1.1.tar.gz
Algorithm Hash digest
SHA256 bc4709be96708ebaf9a0cfc22af0cf3670adc9a0417b8577a72fdd4938c78f87
MD5 e5457a51ab26cf9fe3faae5595afff57
BLAKE2b-256 32b5416b53fc7a690375b3e50a74d3e29e19cce4ed32f2dbc9970f5c393532ac

See more details on using hashes here.

File details

Details for the file django_fernet_encrypted_fields-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: django_fernet_encrypted_fields-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for django_fernet_encrypted_fields-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f14f245969a713c7cc6fc4b7b83684f1b264d5a8635f6bb293be24dcf8035b48
MD5 9b7c2979bfafbf0944b938512ebd8269
BLAKE2b-256 88279f9806a555b6bc379796662d0b6df3a8ba2b8569b185a9e52358baa0a23d

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