Hello,
I'm currently investigating encrypting certain database columns, such as user passwords and other sensitive data such as usernames and social security numbers. The (java) application uses Hibernate and a MySQL database on the backend.
The use case is, username, password, and social security are stored in the database. According to the Jasypt documentation, one should never be able to decrypt the password (the code should just compare digests). That makes sense for passwords. What about for other data, like usernames and social security numbers? This is data that we'll want to encrypt in the database, but would also need to be retrieved. Where would/should the encryption key be stored (so if someone hacks through the system, they cannot decrypt this information from the database)?
Jasypt seems to handle this, but I wanted to confirm with the following, more specific questions:
1. In the application code (business logic), what will this code be working with? More specifically, as mentioned in the article below for encrypting user passwords, it says "you should not even have a way to get to read/know/see your users' passwords, no matter if you are the system administrator". I understand that for passwords, but for other data, like social security numbers or usernames, we'll want to make sure that the data stored in the database is encrypted, but that we can obtain the original data (username and social security number). How does Jasypt handle this, or more importantly, how should this be handled in the application (using Jasypt)?
http://jasypt.org/howtoencryptuserpasswords.html2. If we use Jasypt to encrypt the database column for the user password using a one way digest method, there is no way of someone gaining access to the original password (as you explained in that article).
With regards to the usernames and passwords, these too can be encrypted in the database, but since we need to be able decrypt this information, wouldn't an encryption key need to be stored somewhere (like in the application layer)? Where should this encryption key be stored, so if someone were to hack through the system, they couldn't decrypt these fields? Or maybe there is a better way to do this?
Thanks in advance (and sorry for what could be obvious).