Skip to main content

Django Encrypted Files

Encrypt files uploaded to your Django application.

This package uses AES in CTR mode to encrypt files via an upload handler.

The upload handler encrypts data as it is recieved during upload, so only encrypted data is ever written to temporary files.

Installation

Via pip:

pip install django-dencrypted-files

Usage

Add the encrypted_files app to your INSTALLED_APPS setting: settings.py

INSTALLED_APPS = [
    ...
    'encrypted_files',
    ...
]

Add an encryption key to use. This should be 16, 24, or 32 bytes long:

settings.py

AES_KEY = b'\x1a>\xf8\xcd\xe2\x8e_~V\x14\x98\xc2\x1f\xf9\xea\xf8\xd7c\xb3`!d\xd4\xe3+\xf7Q\x83\xb5~\x8f\xdd'

If you want to encrypt ALL uploaded files, add the EncryptedFileUploadHandler as the first handler:

settings.py

FILE_UPLOAD_HANDLERS = [
    "encrypted_files.uploadhandler.EncryptedFileUploadHandler",
    "django.core.files.uploadhandler.MemoryFileUploadHandler",
    "django.core.files.uploadhandler.TemporaryFileUploadHandler"
]

Use regular FileFields for file uploads. When you want to decrypt the file, use the EncryptedFile helper class

views.py

from .models import ModelWithFile
from encrypted_files.base import EncryptedFile as EF
from django.http import HttpResponse

def decrypted(request,pk):
    f = ModelWithFile.objects.get(pk=pk).file
    ef = EF(f)
    return HttpResponse(ef.read())

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_encrypted_files-0.0.1.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_encrypted_files-0.0.1-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file django_encrypted_files-0.0.1.tar.gz.

File metadata

  • Download URL: django_encrypted_files-0.0.1.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.6

File hashes

Hashes for django_encrypted_files-0.0.1.tar.gz
Algorithm Hash digest
SHA256 87ad79aefab339be6f362e72bb9e49d80a9187cb99d8474af9a7c9f385875ba9
MD5 3fe7cf4ece34176a532848424e01c434
BLAKE2b-256 0516e319e0d29e9bb853833f915212210f8b6600f2e6b4b0a261903f91318490

See more details on using hashes here.

File details

Details for the file django_encrypted_files-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: django_encrypted_files-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.6

File hashes

Hashes for django_encrypted_files-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0213a53dc4db89eadd187520929c25ea1d918c5cd37bc2f39010b185c969b0d1
MD5 a6a571e8e30a10b0ac99d4d353e65c30
BLAKE2b-256 efdc64146cbd58273a602ede8dc0760bc8d96b3ac9ced196d952b6c24f00e7bb

See more details on using hashes here.

Release history Release notifications | RSS feed

0.0.10

2 files

0.0.9

2 files

0.0.8

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

This release

0.0.1 This release

2 files

0.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page