No commit activity in last 3 years
No release in over 3 years
Ruby gem to prompt for password at run time for attr_encrypted
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies
 Project Readme

Encryption Activator

This gem lets you encrypt fields in your Rails app's database, and by default, raise an exception if you try to access any of the fields, until you call the prompt method which will ask for the encryption key.

Examples

gem 'encryption_activator'

EncryptionActivator.key     # raises EncryptionActivator::KeyNotSetException
EncryptionActivator.prompt  # prompts for key at the terminal
EncryptionActivator.key     # => returns key

Use with Rails: attr_encrypted

Key-less mode

Put this in eg. config/initializers/activerecord_attr_encrypted.rb :

ActiveRecord::Base.attr_encrypted_options.merge!(
  key:    EncryptionActivator.keyproc,
  encode: true
)

Your app will work without the key being set, as long as you don't try to read any of the encrypted fields.

Activate encrypted mode

Somewhere in your worker process or startup thread, you call this:

EncryptionActivator.prompt

After this, the app can read and write the encrypted fields.

OR you can use the environment variable ENCRYPTION_ACTIVATOR_KEY