Module: Slosilo::Migration::EncryptedAttributes
- Defined in:
- lib/slosilo/migration/attr_encrypted.rb
Overview
we don’t trust the database to keep all backups safe from the prying eyes so we encrypt sensitive attributes before storing them
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
- .cipher ⇒ Object
- .decrypt(ctxt) ⇒ Object
- .encrypt(value) ⇒ Object
- .included(base) ⇒ Object
- .key ⇒ Object
Class Method Details
.cipher ⇒ Object
44 45 46 |
# File 'lib/slosilo/migration/attr_encrypted.rb', line 44 def cipher @cipher ||= Slosilo::Migration::Symmetric.new end |
.decrypt(ctxt) ⇒ Object
35 36 37 38 |
# File 'lib/slosilo/migration/attr_encrypted.rb', line 35 def decrypt ctxt return nil unless ctxt cipher.decrypt ctxt, key: key end |
.encrypt(value) ⇒ Object
30 31 32 33 |
# File 'lib/slosilo/migration/attr_encrypted.rb', line 30 def encrypt value return nil unless value cipher.encrypt value, key: key end |
.included(base) ⇒ Object
25 26 27 |
# File 'lib/slosilo/migration/attr_encrypted.rb', line 25 def self.included base base.extend ClassMethods end |
.key ⇒ Object
40 41 42 |
# File 'lib/slosilo/migration/attr_encrypted.rb', line 40 def key Slosilo::encryption_key || (raise "Please set Slosilo::encryption_key") end |