As a Django framework user, I often encounter myself needing to encrypt one or more model fields. Over the years, I’ve used several easy to use encrypted fields projects that provided access to encrypted version of widely used fields such as EncryptedCharField
, EncryptedTextField
and others.
Sadly, most of the packages I’ve used have been deprecated, including https://github.com/defrex/django-encrypted-fields and https://github.com/orcasgit/django-fernet-fields.
For these reasons, I put together a set of Django encrypted fields backed by Google Tink, a widely used cryptography library with robust support for managing keysets and integrations with cloud KMS systems.
To get started:
|
|
Then, create a stanza in settings.py
for TINK_FIELDS_CONFIG
:
|
|
You can create Tink keysets via
tinkey
. Click here to learn more.
With that in place, you can simply make use of fields avaialble in tink_fields.fields
such as EncryptedCharField
, EncryptedTextField
and more:
|
|
For full documentation visit https://github.com/script3r/django-tink-fields.