You should be able to generate a pair of public and private keys on your personal machine, and then publish the public key in your application so that the data can be encrypted. Thus, the server never sees the private key, and if the server is hacked, the data is still safe.
You want to make sure that the entire transaction is through SSL. The client side can generate a random session key, encrypt data using this key (using AES), then encrypt the key using the public key from your application (using RSA) and send encrypted data and the key to the server. You can save the entire block in one database field or two. The only way to decrypt data is to decrypt the key first, and the only way to do this is to use the private key on your personal machine.
Update
Check out http://plugins.jquery.com/project/jQuery-Gibberish-AES . This is a jQuery plugin that allows you to enable this type of script. I have no experience using it, but it seems to me that this is a good start.
New update
Just to understand what I am suggesting and refer to your editing:
You cannot use AES encryption only. AES has one key that is used for encryption and decryption. The key must exist wherever the encryption operation occurs, either in the client code or on the web server. In the first case, anyone can get your key. In the second case, if the web server is hacked, the key and data are also at risk.
The solution is to use good, strong AES encryption in combination with public key cryptography (RSA). I would suggest doing client-side cryptography because I will describe below. Here, however, there are steps that I propose:
- On your private machine, create a pair of public / private keys and keep the private key safe.
- Put the public key in the code that you send to the client.
- When a user submits a form to client code:
- Generates a random AES key (session key)
- Encrypts form data
- Uses your public key and RSA algorithm to encrypt the session key
- Cancels a plaintext session key.
- Sends encrypted form data and an encrypted session key to your server.
- The server receives the data in an encrypted form and stores it together with the encrypted key in the database.
Now you have the encrypted data in the database, which can only be obtained using the private key stored on your private machine. Even if the user somehow manages to capture the session key while he is in a box on his machine, the worst that can happen is that one record can be decrypted.
The reason I propose this approach on the client side is because it means that your server never sees the encryption keys explicitly. If the same scheme is used on the server side, theoretically, an attacker can sit on your server, watching how this happens. In the end, it basically comes down to how you want to be paranoid.
Following this scheme, when you want to receive data, you must dump the required data in encrypted form from the database to your personal machine. For each piece of encrypted data:
- Decrypt the session key using the RSA algorithm and your private key
- Decrypt the data using AES using the session key from step 1.
In any case, I would suggest this approach. I am sure that there are libraries.