How do I provide encryption for all the data in a public application?
March 23, 2005 3:44 PM
Subscribe
How should I keep data encrypted in my database? (php, mysql help)
I’ve built a web-based note taking / to do application that I’ve been finding extremely useful. I’d like to set up a user database and let some friends, and eventually maybe the public, use it. To retain privacy I’d rather not be able to see the content in a readable form in the database. How can I do this? I’ve thought about using something like mcrypt to encrypt all the strings and decrypt them with their own key, but how does one deal with a forgotten key? Is there someway to store the key in the database itself? Would they need to log enter the key at each log-in? Is it safe to store it as a cookie?
I’m sure there’s a fairly simple method of doing this, but I can’t think of it. The platform is PHP 4.3.1 and MySql. My level of knowledge is pretty high, but all self-taught.
Also, I’m happy to hear any other stories about doing something like this and maybe some issues I haven’t even thought of.
posted by miniape to computers & internet (10 comments total)
The easiest way by far to do what you're intending, which is to keep users from reading each others data, is to enforce very strict program-side requirements for a username field, and to have the user log in. Another way to do it would be to create a separate database and MySQL user id (assuming this isn't on a shared hosting platform) for each user and use MySQL's permissions systems to partition things off.
Encryption is quite possibly a waste of your time. It's good to keep things like passwords encrypted, but if you're just trying to keep people from reading each other's notes ... not worth going through it.
(OTOH, it might be worth considering ... if you are trying to protect people's data from third party attackers. Even then, you face man-in-the-middle attacks that involve intercepting the remote key, combining it with your local key, and decrypting the data.)
posted by SpecialK at 4:36 PM on March 23, 2005