class EncryptData::Crypt

Constants

ALGO

Public Class Methods

crypt(cipher_method, value) click to toggle source
# File lib/encrypt_data/crypt.rb, line 20
def crypt(cipher_method, value)
  cipher = OpenSSL::Cipher.new(ALGO)
  cipher.send(cipher_method)
  cipher.pkcs5_keyivgen(encryption_key)
  result = cipher.update(value)
  result << cipher.final
end
decrypt(value, key) click to toggle source
# File lib/encrypt_data/crypt.rb, line 9
def decrypt(value, key)
  @key = key
  crypt(:decrypt, value)
end
encrypt(value, key) click to toggle source
# File lib/encrypt_data/crypt.rb, line 4
def encrypt(value, key)
  @key = key
  crypt(:encrypt, value)
end
encryption_key() click to toggle source
# File lib/encrypt_data/crypt.rb, line 14
def encryption_key
  @master_key = ENV['EncryptDataKey'].nil? ? EncryptData.configuration.master_key : ENV['EncryptDataKey']
  @key || @master_key
end