Skip to main content

Symmetric encryption helper (Fernet) for Volkanos Django modules

Project description

django-crypt

Symmetric encryption helper (Fernet) for Volkanos Django modules. Wraps cryptography.fernet with a salt loaded from settings.CRYPT_SALT.

Quick Start

Requires Python 3.11+.

make install   # uv venv + install deps
make test      # run tests
make lint      # ruff check + format

Usage

from django_crypt import Crypt

# Encrypt / decrypt
crypt = Crypt()                            # uses settings.CRYPT_SALT
encrypted = crypt.encrypt("secret value")
decrypted = crypt.decrypt(encrypted)
assert decrypted == "secret value"

# Generate fresh salt (for first-time setup)
salt = Crypt.generate_salt()               # static method
print(f"Save this in settings.CRYPT_SALT: {salt}")

Management Commands

python manage.py generate_salt           # generate fresh salt
python manage.py encrypt "plain text"    # encrypt a string
python manage.py decrypt "<ciphertext>"  # decrypt a string

Settings

# In Django settings.py
CRYPT_SALT = "<output of generate_salt>"
INSTALLED_APPS = [..., "django_crypt"]

Important

Fernet ciphertexts are non-deterministic — encrypting the same plaintext twice yields different ciphertexts. For deterministic lookup hashing (e.g. unique-indexed code lookup), use a separate HMAC-SHA256 helper, not Crypt.encrypt().

Details

See AGENTS.md for architecture and integration details.

Project details


Download files

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

Source Distribution

entirius_django_crypt-2.0.0.tar.gz (39.9 kB view details)

Uploaded Source

Built Distribution

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

entirius_django_crypt-2.0.0-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file entirius_django_crypt-2.0.0.tar.gz.

File metadata

  • Download URL: entirius_django_crypt-2.0.0.tar.gz
  • Upload date:
  • Size: 39.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for entirius_django_crypt-2.0.0.tar.gz
Algorithm Hash digest
SHA256 9c4ae51c3f08b68d8f5562d7919c6a2f4c8f8671c478136e7501c127bd2bbf58
MD5 fd653633c66785dc9cf0d930fc9572d7
BLAKE2b-256 7b68394c3aff094a3e907101812c74b226a27a67ef7335f6111757bc59f43315

See more details on using hashes here.

File details

Details for the file entirius_django_crypt-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: entirius_django_crypt-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 11.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for entirius_django_crypt-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1f31cf81856792cff53154ff8f5eb5e406716741298fdb4da41935250f766ab3
MD5 77f1e140f8523ab092f9dcd7b9d3a95c
BLAKE2b-256 3bda9e40e82f51d962bc9ea90dcd7ede3378e121ea5b3978085494204658d791

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page