title: Database encryption in Rails
body: <p>I am using the ActiveRecord <code>serialize</code> method with a class of my own, <code>AESCoder</code>. This will uses aes-256-cbc with a random initialization vector every time. This initialization vector is prepended to the field when I store it in the database, and is of course extracted before deserializing.</p>
  
  <p>Now, this scheme prevents me from using any finders on those attributes. I have to select all the rows I need, which will be automatically decrypted, and the perform a ruby <code>select</code> on the item list. This is, of course, a huge performance bottleneck, which I can't afford for this application.</p>
  
  <p>One solution would be not to use a random IV, but then aes-256-cbc wouldn't be as secure any more.</p>
  
  <p>Am I overlooking something here?</p>