Search code examples
djangodjango-email

Can I hash/encrypt or otherwise protect emails in my Django app from hackers?


Hoping for a simple function I can use to store emails securely and retrieve easily when required to send emails.


Solution

  • Kind of a general question, but here are a few solutions I'm familiar with:

    • use django-encrypted-fields, which has an EncryptedEmailField
    • you can override the save method for encrypting the email yourself, then override the post_init signal for decryption. See example here (which is based on this)
    • you can build your own encrypted email field, see django snippet here (uses pyCrypto)
    • you can use django-extension's EncryptedCharField
    • If none of the above seems good enough, try google-ing around by yourself. You're probably not the first to tackle this problem

    good luck.