Module: Slosilo::EncryptedAttributes
- Defined in:
- lib/slosilo/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, opts = {}) ⇒ Object
- .encrypt(value, opts = {}) ⇒ Object
- .included(base) ⇒ Object
- .key ⇒ Object
Class Method Details
.cipher ⇒ Object
67 68 69 |
# File 'lib/slosilo/attr_encrypted.rb', line 67 def cipher @cipher ||= Slosilo::Symmetric.new end |
.decrypt(ctxt, opts = {}) ⇒ Object
58 59 60 61 |
# File 'lib/slosilo/attr_encrypted.rb', line 58 def decrypt ctxt, opts={} return nil unless ctxt cipher.decrypt ctxt, key: key, aad: opts[:aad] end |
.encrypt(value, opts = {}) ⇒ Object
53 54 55 56 |
# File 'lib/slosilo/attr_encrypted.rb', line 53 def encrypt value, opts={} return nil unless value cipher.encrypt value, key: key, aad: opts[:aad] end |
.included(base) ⇒ Object
48 49 50 |
# File 'lib/slosilo/attr_encrypted.rb', line 48 def self.included base base.extend ClassMethods end |
.key ⇒ Object
63 64 65 |
# File 'lib/slosilo/attr_encrypted.rb', line 63 def key Slosilo::encryption_key || (raise "Please set Slosilo::encryption_key") end |