Last active
December 19, 2015 23:49
-
-
Save adityagodbole/6036935 to your computer and use it in GitHub Desktop.
The gen attr_encrypted is a very popular option to get DB independent and framework independent encryption. It is known to work with -
- ActiveRecord
- DataMapper
- Mongoid see here for required tweaks
- Sequel
It offers the following features:
- Specify attributes to be encrypted -
attr_encrypted :ssn, :key => 'a secret key'
- Specify alternate attribute name -
attr_encrypted :email, :key => 'a secret key', :attribute => 'email_encrypted'
- Calculate encryption keys dynamically
-
- by specifying a method -
attr_encrypted :email, :key => :get_key
- by specifying a method -
-
- by specifying a proc -
attr_encrypted :email, :key => proc { |user| user.key }
- by specifying a proc -
- Specify custom encryptors
- All encryption algorithms suported by the Encryptor gem
- Store any serialisable data in the encrypted field -
attr_encrypted :credentials, :key => 'some secret key', :marshal => true
Different databases provide transparent, client independent database encryption mechanisms. This makes the encryption transparent to the client programs and is relatively faster. This comes at a cost to the ease of implementation and supported encryption algorithms.
- Postgres - Postgres provides the pgcrypto module to handle encryption
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment