A Django app providing a custom model field for storing sensitive information.
Project description
encrypted_text_field Django App
encrypted_text_field is a Django app providing a custom model field for storing sensitive information like passwords and API keys. The data is encrypted before being saved to the database and decrypted when accessed through Django's ORM in views or other business logic. The field will be rendered in Django's admin but ensures that values are not readable or displayed back in the UI, protecting sensitive information from exposure.
Features
- EncryptedTextField Model Field: Encrypt and decrypt data automatically.
- Security in Django Admin: Displays a password widget in the admin interface to edit fields without showing existing values.
- Generate Keys via Management Command: Includes a Django management command to generate new encryption keys.
Requirements
- Django 3.2 or newer
- Cryptography
Intallation using PIP
pip install encrypted-text-field
Installation via GitHub
Follow these steps to install and use the encrypted_text_field in your Django project:
-
Install the package
Clone this repository into an empty folder within your Django project directory:
git clone https://github.com/codingcowde/encrypted_text_field.git
Setup
-
Add
encrypted_text_fieldto yourINSTALLED_APPSINSTALLED_APPS = [ ... 'encrypted_text_field', ... ]
-
Configure the Encryption Key
In your settings module, set the encryption key:
ENCRYPTION_KEY = 'your_generated_encryption_key_here'
Note: This key should be generated securely and kept secret. Use environment variables to manage keys securely in production.
-
Run Migrations
python manage.py migrate
Usage
To use EncryptedTextField in your models:
from django.db import models
from encrypted_text_field.models import EncryptedTextField
class MyModel(models.Model):
secret_data = EncryptedTextField()
Admin Interface
In the admin interface, EncryptedTextField will appear as a password input. The actual data is never displayed in the admin to prevent leakage of sensitive information.
Generating a New Encryption Key
Run the following management command to generate a new encryption key:
python manage.py generate_encryption_key
Follow the instructions provided by the command output to replace your existing encryption key.
Contributing
Contributions are welcome!
License
Distributed under the MIT License. See LICENSE for more information.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file encrypted_text_field-0.1.1.tar.gz.
File metadata
- Download URL: encrypted_text_field-0.1.1.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cffcf8095d1c0d47420916a3e3f4c266ef363cb1a6525e51c41fd18bb87ef44e
|
|
| MD5 |
52f313b3f00baceefab2c4a914361352
|
|
| BLAKE2b-256 |
58e1516a3fab0ac154470adb67184dc1085fcdd8ec290f721470e73d1c8227f4
|
File details
Details for the file encrypted_text_field-0.1.1-py3-none-any.whl.
File metadata
- Download URL: encrypted_text_field-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
15e177d5bc43a130c8666c95577631c4f24f82acf735111fde0d43b99194db34
|
|
| MD5 |
0a4e362cc48d07e7e32c0bec7910024f
|
|
| BLAKE2b-256 |
04806b615913c8955da53c2282972f545494eb4280411031e40024d454f1bad2
|