title: Advice on integrating a previously created database that contains encrypted fields into a Rails app
body: <p>I am looking for some advice on how I could go about integrating an encrypted, pre-existing database into a Rails app .  I already have experience on how I can access the table data when the data is in plaintext; this is simply specifying the connection to the database, and referencing the field names correctly.  Yet, what would need to be done when some (or all) of the field are encrypted?</p>
  
  <p>Background:</p>
  
  <p>I have a push service from a 3rd party that is populating a staging server database (currently in plaintext).  I am able to access the data without problems, but I would like to have the service send the sensitive information to the staging database in encrypted form (i.e. data would already be encrypted in transit and stored in encrypted form).</p>
  
  <p>The result of doing this, however, would mean that I would need to decrypt some (or all) fields before accessing them.  What would be some simple approaches to performing this?  I would need to be able to perform searches on the fields, and would need the existing access methods (e.g. <code>MODEL_OBJECT#attribute_name</code>, <code>MODEL_NAME#where</code>, <code>MODEL#find_by</code>) when applied to plaintext to be reused so as to not have to refactor the hell out of the code.</p>
  
  <p>There would be an assumption that I can obtain decryption data (key, salt) and the algorithm used by the 3rd party to encrypt the data being sent to me.  I've looked at some of the gems like <code>crypt_keeper</code> (i've used this one in the past), <code>attr_encrypted</code>, and <code>symmetric_encryption</code>, but I'm not sure which would be most appropriate.  I'd like to avoid the wild goose chase.</p>