class Lite::Encryption::Schemes::Deterministic

Public Instance Methods

decrypt(value, _opts = {}) click to toggle source
# File lib/lite/encryption/schemes/deterministic.rb, line 10
def decrypt(value, _opts = {})
  decoded_value = Base64.strict_decode64(value)
  crypt(:decrypt, decoded_value)
end
encrypt(value, _opts = {}) click to toggle source
# File lib/lite/encryption/schemes/deterministic.rb, line 15
def encrypt(value, _opts = {})
  encoded_value = crypt(:encrypt, value)
  Base64.strict_encode64(encoded_value)
end

Private Instance Methods

cipher() click to toggle source
# File lib/lite/encryption/schemes/deterministic.rb, line 22
def cipher
  @cipher ||= Lite::Encryption::Key::CIPHER.dup
end
crypt(cipher_method, value) click to toggle source
# File lib/lite/encryption/schemes/deterministic.rb, line 26
def crypt(cipher_method, value)
  cipher.send(cipher_method)
  cipher.key = Lite::Encryption.configuration.encryption_salt
  cipher.iv = Lite::Encryption.configuration.encryption_iv
  cipher.update(value)
end