Package: django-safe-fields
django-safe-fieldsSave field value encrypted to database.Installpipinstalldjango-safe-fieldsShipped FieldsMixinsSafeFieldMixinBaseSafeStringFieldMixinSafeNumbericFieldMixinBase # used for fields that using none numberic database backendFields & Instance Extra Init Parameters (You can use django's fields default parameters)SafeCharFieldpassword: default to settings.SECRET_KEY.cipher_class: choices are cipherutils.AesCipher, cipherutils.S12Cipher or something similar. default to cipherutils.AesCipher.kwargsNote: kwargs parameters depend on the cipher class you choose. see details athttps://pypi.org/project/fastutils/.cipher: or you can provides cipher instance instead of cipher_class and class parameters. Has higher priority than cipher_class.SafeTextFieldSame as SafeCharFieldSafeEmailFieldSame as SafeCharFieldSafeURLFieldSame as SafeCharFieldSafeGenericIPAddressFieldSame as SafeCharFieldSafeIntegerFieldNote: no extra init parametersSafeBigIntegerField # using varchar(max_length=128) in datatabase storagepasswordkwargsint_digits: default to 12SafeFloatField # using varchar(max_length=128) in database storage.passwordkwargsint_digits: default to 12float_digits: default to 4NoteDefault cipher class is MysqlAesCipher. It keeps the same with mysql's aes_encrypt and aes_decrypt when the mysql's server variable block_encryption_mode=aes-128-ecb. The main trick is the method used to prepair the final key from the password.Default password is settings.SECRET_KEY, but we STRONGLY suggest you use different password for every different field.Usagepro/settings.pyINSTALLED_APPS = [
    ...
    'django_safe_fields',
    ...
]Insertdjango_safe_fieldsinto INSTALLED_APPS.app/models.pyfrom django.db import models
from django.conf import settings
from django_safe_fields.fields import SafeCharField
from django_safe_fields.fields import SafeGenericIPAddressField
from django_safe_fields.fields import SafeIntegerField
from fastutils.cipherutils import S12Cipher
from fastutils.cipherutils import HexlifyEncoder

class Account(models.Model):
    username = SafeCharField(max_length=64)
    name = SafeCharField(max_length=64, cipher_class=S12Cipher)
    email = SafeCharField(max_length=128, null=True, blank=True, cipher=S12Cipher(password=settings.SECRET_KEY, encoder=HexlifyEncoder(), force_text=True))
    last_login_ip = SafeGenericIPAddressField(max_length=256, null=True, blank=True, password="THIS FIELD PASSWORD")
    level = SafeIntegerField(null=True, blank=True)

    def __str__(self):
        return self.usernameAll fields will be stored with encryption.Aes is a strong cipher.With aes encryption, you can NOT search partly, only theexactsearch rule will be accepted.With aes encryption, you can NOT sort.S12Cipher is string encode method that keeps the sorting result after encoded.IvCihper is a week cipher for integer field that let you sort with the field.Test Passed On Python and Django Versionspython27:~=django1.11.29python34:~=django1.11.29python34:~=django2.0.13python35:~=django1.11.29python35:~=django2.0.13python35:~=django2.1.15python35:~=django2.2.28python36:~=django2.0.13python36:~=django2.1.15python36:~=django2.2.28python36:~=django3.0.14python36:~=django3.1.14python36:~=django3.2.21python37:~=django2.0.13python37:~=django2.1.15python37:~=django2.2.28python37:~=django3.0.14python37:~=django3.1.14python37:~=django3.2.21python38:~=django2.0.13python38:~=django2.1.15python38:~=django2.2.28python38:~=django3.0.14python38:~=django3.1.14python38:~=django3.2.21python38:~=django4.0.10python38:~=django4.1.11python38:~=django4.2.5python39:~=django2.0.13python39:~=django2.1.15python39:~=django2.2.28python39:~=django3.0.14python39:~=django3.1.14python39:~=django3.2.21python39:~=django4.0.10python39:~=django4.1.11python39:~=django4.2.5python310:~=django2.1.15python310:~=django2.2.28python310:~=django3.0.14python310:~=django3.1.14python310:~=django3.2.21python310:~=django4.0.10python310:~=django4.1.11python310:~=django4.2.5python311:~=django2.2.28python311:~=django3.0.14python311:~=django3.1.14python311:~=django3.2.21python311:~=django4.0.10python311:~=django4.1.11python311:~=django4.2.5Releasesv0.2.2Fix fastutils.strutils.force_text problem. Use zenutils.sixutils.TEXT instead.v0.2.1Fix problem with latest version of fastutils.v0.1.11Fix callable default value problem.v0.1.7Add used_ciphers parameters support, so that we can decrypt old data when we change cipher_class or field password.Add safe field management commands: list_safe_fields, mapping_cipher_fields_dumps.Note:Use mapping_cipher_fields_dumps to speed up the safe field initialization.v0.1.6Fix xxx__in query problem.v0.1.5Turn to bytes before doing encryption.v0.1.4Change init parameter encoder to result_encoder.v0.1.3Fix get_db_prep_lookup problem.v0.1.2Add SafeBigIntegerField and SafeFloatField.v0.1.1Fix problem in objects.get that double encrypt the raw data.v0.1.0First release.