module Slosilo::EncryptedAttributes

we don't trust the database to keep all backups safe from the prying eyes so we encrypt sensitive attributes before storing them

Public Class Methods

cipher() click to toggle source
# File lib/slosilo/attr_encrypted.rb, line 67
def cipher
  @cipher ||= Slosilo::Symmetric.new
end
decrypt(ctxt, opts={}) click to toggle source
# 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={}) click to toggle source
# 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) click to toggle source
# File lib/slosilo/attr_encrypted.rb, line 48
def self.included base
  base.extend ClassMethods
end
key() click to toggle source
# File lib/slosilo/attr_encrypted.rb, line 63
def key
  Slosilo::encryption_key || (raise "Please set Slosilo::encryption_key")
end