5136d80  

--  
Justin Mazzi


On Friday, October 18, 2013 at 2:41 PM, Mike Boone wrote:

> In README.md (http://README.md):
> > + `CREATE EXTENSION IF NOT EXISTS pgcrypto` > + * ActiveRecord logs are [automatically](https://github.com/jmazzi/crypt_keeper/blob/master/lib/crypt_keeper/log_subscriber/postgres_pgp.rb) > + filtered for you to protect senitive data from being logged. > + * Custom options can be set through the `:pgcrypto_options`. E.g. `crypt_keeper :field, encryptor: :postgres_pgp, pgcrypto_options: 'compress-level=9' > + > +## Searching > +Searching ciphertext is a complex problem that varies depending on the encryption algorithm you choose. All of the bundled providers include search support, but they have some caveats. > + > +* AES > + * The Ruby implementation of AES uses a random initialization vector. The same plaintext encrypted multiple times will have different output each time for the ciphertext. Since this is the case, it is not possible to search leveraging the database. Database rows will need to be filtered in memory. It is suggested that you use a scope or ActiveRecord batches to narrow the results before seaching them. > + > +* Mysql AES > + * Surprisingly, MySQL's implementation of AES does not use a random initialization vector. The column containing the ciphertext can be indexed and searched quickly. > + > +* PostgresSQL PGP > + * PGP also uses a random initialization vector which means it generates unique output each time you encrypt plaintext. Although the database can be searched by performing row level decription and comparing the plaintext, it will not be able to use an index. A scope or batch is suggested when searching.  
> typo "decription"
>  
> —
> Reply to this email directly or view it on GitHub (https://github.com/jmazzi/crypt_keeper/pull/53/files#r7070313).
>  
>  
>