Registry / auth-security / django-cryptography-5

django-cryptography-5

JSON →
library2.0.3pypypiunverified

django-cryptography provides encryption for Django model fields using AES. Current version 2.0.3, with a focus on simplicity and Django ORM integration. Release cadence is low; maintained by saaspegasus.

pip install django-cryptography
INSTALL
IMPORT
SIG · DJANGO-CRYPTOGRAPH
D
django-cryptography-5
auth-securitypythonv2.0.3
Install
4.2s avg
Import
Disk
181MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v? · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 144.6MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 4.2s · import 0.000s · 216MB
181MB installed
● package 181MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

EncryptedCharField
from django_cryptography import EncryptedCharField
from django_cryptography.fields import EncryptedCharField

Define an encrypted char field in a Django model.

import os import django os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myproject.settings') django.setup() from django_cryptography.fields import EncryptedCharField from django.db import models class MyModel(models.Model): secret = EncryptedCharField(max_length=255) # Now you can create and save instances normally: instance = MyModel.objects.create(secret='my secret') print(instance.secret) # Output: 'my secret'
Debug
Known issues
gotchaEncrypted fields are not sortable or filterable by their encrypted values. Querying by encrypted field will not work as expected.
fix
Do not use encrypted fields in `filter()`, `order_by()`, or indexing. Consider using a non-encrypted field or hashing for lookups.
affects: all
gotchaIf you change the `SECRET_KEY` in Django settings, all existing encrypted data will become undecryptable. There is no built-in key rotation.
fix
Back up existing data before changing SECRET_KEY. Implement manual re-encryption if key rotation is needed.
affects: all
deprecatedThe package was previously named `django-cryptography` and later `django-encrypt`? Actually, the correct import path changed from `encrypt` to `django_cryptography`. Ensure you are not using the old import.
fix
Update imports to `from django_cryptography.fields import ...`
affects: <2.0
Upgrade
Version history
2.0.3latest on PyPI · released Jan 28, 2025
Audit
Dependencies
pycryptodomeoptionalCryptographic operations
Agent activity
21 hits · last 30 days
node
18
OpenAI (training)
1
Resources
django-cryptography-5 — pip install django-cryptography-5 · libregistry