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
Installation
Follow these steps to install and use the encrypted_text_field
in your Django project:
-
Install the package
Clone this repository into your Django project directory:
git clone https://github.com/codingcowde/encrypted_text_field.git
-
Add
encrypted_text_field
to yourINSTALLED_APPS
INSTALLED_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
Hashes for encrypted_text_field-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d5e412bc7695a36b58f1a72cbe1d88755845e21014bc4fe2084cfa4d1c9dda73 |
|
MD5 | f19c177c590b71b11163ef50825e5239 |
|
BLAKE2b-256 | 9f462555d73139bfddcb95e8871b346d38b78f4c69621a8c3b503e5e70a9205f |
Hashes for encrypted_text_field-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ac013d3065c31fd8a1df4af90127a0ded5a7563dfb290bfd814832997038c2f |
|
MD5 | 3ab188428e1e5c3bf9d70c67aa7d01dc |
|
BLAKE2b-256 | 9b4a4151b173261a4d7309bfafcf80f6d030debde81a1b246f8eeba0cc2741d5 |