Skip to content

georgemarshall/django-cryptography

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Feb 16, 2024
a5cde9b · Feb 16, 2024
Feb 16, 2024
Apr 19, 2023
Apr 18, 2023
Apr 18, 2023
Apr 7, 2022
Mar 2, 2016
Apr 19, 2023
Mar 7, 2016
May 25, 2022
Apr 18, 2023
Apr 19, 2023
May 25, 2022
May 25, 2022

Repository files navigation

Django Cryptography

A set of primitives for easily encrypting data in Django, wrapping the Python Cryptography library. Also provided is a drop in replacement for Django's own cryptographic primitives, using Cryptography as the backend provider.

Do not forget to read the documentation.

GitHub Workflow Status (branch) Codecov branch

Cryptography by example

Using symmetrical encryption to store sensitive data in the database. Wrap the desired model field with encrypt to easily protect its contents.

from django.db import models

from django_cryptography.fields import encrypt


class MyModel(models.Model):
    name = models.CharField(max_length=50)
    sensitive_data = encrypt(models.CharField(max_length=50))

The data will now be automatically encrypted when saved to the database. encrypt uses an encryption that allows for bi-directional data retrieval.

Requirements

Installation

pip install django-cryptography