https://github.com/georgemarshall/django-cryptography
Easily encrypt data in Django
https://github.com/georgemarshall/django-cryptography
django python
Last synced: 9 months ago
JSON representation
Easily encrypt data in Django
- Host: GitHub
- URL: https://github.com/georgemarshall/django-cryptography
- Owner: georgemarshall
- License: bsd-3-clause
- Created: 2016-03-02T07:55:01.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2024-11-18T05:40:33.000Z (about 1 year ago)
- Last Synced: 2025-05-08T23:34:02.665Z (9 months ago)
- Topics: django, python
- Language: Python
- Homepage: https://django-cryptography.readthedocs.io/
- Size: 223 KB
- Stars: 393
- Watchers: 17
- Forks: 86
- Open Issues: 48
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
- fucking-awesome-cryptography - django-cryptography - Easily encrypt data in Django. (Frameworks and Libs / Python)
- awesome-django-security - Django Cryptography
- awesome-cryptography - django-cryptography - Easily encrypt data in Django. (Frameworks and Libs / Python)
README
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_.
.. START HIDDEN
.. image:: https://img.shields.io/github/workflow/status/georgemarshall/django-cryptography/CI/master
:target: https://github.com/georgemarshall/django-cryptography/actions/workflows/main.yml
:alt: GitHub Workflow Status (branch)
.. image:: https://img.shields.io/codecov/c/github/georgemarshall/django-cryptography/master
:target: https://app.codecov.io/gh/georgemarshall/django-cryptography/branch/master
:alt: Codecov branch
.. END HIDDEN
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.
.. code-block:: python
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
------------
* Python_ (3.7, 3.8, 3.9, 3.10, 3.11)
* Cryptography_ (2.0+)
* Django_ (3.2, 4.1, 4.2)
Installation
------------
.. code-block:: console
pip install django-cryptography
.. _Cryptography: https://cryptography.io/
.. _Django: https://www.djangoproject.com/
.. _Python: https://www.python.org/
.. _documentation: https://django-cryptography.readthedocs.io/en/latest/