Sending password-protected files via email from Django on Ubuntu

Hey everyone, I’m working on a Django project hosted on Ubuntu. I need to send sensitive info to users through email, but I want to make sure it’s super secure.

I’m thinking about encrypting the files before sending them out. The idea is to use a password that I’ll give to the users separately (not in the email). This way, even if someone intercepts the email or somehow gets access to it, they won’t be able to read the contents without the password.

I’m not sure what encryption method to use though. It needs to be something that works well with Django and Ubuntu, but also easy for the recipients to decrypt on their computers, whether they’re using Windows or Mac.

Any suggestions on good encryption tools or methods for this setup? Bonus points if you can share a simple code example of how to implement it in Django! Thanks in advance for your help!

hey there! have u thought about using gpg? it’s pretty cool for encrypting files. works great with django and ubuntu, plus it’s easy for users to decrypt on any OS. u could use python-gnupg library to handle the encryption in ur django app. maybe give that a shot? curious to hear what u end up going with!

For your Django project on Ubuntu, consider using AES encryption with the Python cryptography library. This method is robust, widely compatible, and relatively straightforward. You can encrypt the file before attaching it to the email and generate a unique encryption key for each file. It is important to store the key securely in your database, associating it with the relevant user or transaction. After emailing the encrypted file, send the decryption key through a separate secure channel such as SMS or a secure in-app message.

This approach ensures that even if the email is intercepted, the file remains secure. Recipients using Windows or Mac can decrypt the file with available tools, provided they have clear instructions on the decryption process.

hey ClimbingMonkey, have u checked out AES encryption? it’s pretty solid for what ur after. u can use the cryptography library in python to encrypt files, then zip em up. recipients can easily decrypt with common tools. here’s a quick tip: make sure to securely share the encryption key separately from the email. good luck with ur project!