Provides transparent encryption for ActiveRecord. It is encryption agnostic. You can guard your data with any encryption algorithm you want. All you need is a simple class that does 3 things.
- Takes a hash argument for
- Provides an
encryptmethod that returns the encrypted string
- Provides a
decryptmethod that returns the plaintext
Use can see an AES example here here
The options available were either too complicated under the hood or had weird edge cases that made the library hard to use. I wanted to write something simple that just works.
class MyModel < ActiveRecord::Base crypt_keeper :field, :other_field, encryptor: Aes, passphrase: 'super_good_password' end model = MyModel.new(field: 'sometext') model.save! #=> Your data is now encrypted model.field #=> 'sometext'
It works with all persistences methods:
Add this line to your application's Gemfile:
And then execute:
Or install it yourself as:
$ gem install crypt_keeper
- Fork it
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Add some feature')
- Push to the branch (
git push origin my-new-feature)
- Create new Pull Request