Skip to content

shah-dhwanil/Django-CryptographicFields

Django-CryptographicFields

A Django app for using cryptography in Django Models. It support bi-directional cryptography.

Check out the documentation :- Django-CryptographicFields

Requirements

  • Python (3.6+)
  • Pycryptodome (3.9+)
  • Django (3.0+)
  • Timestring (1.6.0+) Mandatory if python < 3.7

Quick start

1.Install Django-CryptographicFields

Install Django CryptographicFields using PIP:-

pip install Django-CryptographicFields

2. Add "CryptographicFields" to your INSTALLED_APPS setting like this:

    INSTALLED_APPS = [
        ...
        'CryptographicFields',
    ]

3.Custom Encryption Key

Set custom Encryption Key in settings.py Make sure that key length is greater than or equal to 50 otherwise it will raise an error

CRYPTOGRAPHIC_KEY="your_key"

Creating Models using CryptographicFields

Cryptography by example

from CryptographicFields import fields
from django.db import models

class CryptogaphicModel(models.Model):
    name=fields.CharField(max_length=120)

The data will now be automatically encrypted when saved to the database.& decrypted when data is retrieved.

Advantages over other projects:-

  1. Supports data retrival
  2. Supports custom query
  3. Supports Q() queries
  4. Supports Ordering data through python functions
  5. Supports Sorting data through python functions
  6. Supports 'startswith' lookups for all String Based Fields
  7. Supports 'date' lookup for Date,DateTime Fields
  8. Supports 'time' lookup for TimeField

For More Information check out the documentation :- Django-CryptographicFields