module EncryptedField::ControllerAdditions

Public Instance Methods

decrypt_encrypted_field(value) click to toggle source
# File lib/encrypted_field/controller_additions.rb, line 7
def decrypt_encrypted_field(value)
  @private_key ||= OpenSSL::PKey::RSA.new(File.read("#{ENV['CONFIG_CERTIFICATE_PATH']}/encrypted_field_private_key.pem"))
  @private_key.private_decrypt(Base64.decode64(value))
end
encrypt_encrypted_field(value) click to toggle source
# File lib/encrypted_field/controller_additions.rb, line 11
def encrypt_encrypted_field(value)
  @private_key ||= OpenSSL::PKey::RSA.new(File.read("#{ENV['CONFIG_CERTIFICATE_PATH']}/encrypted_field_public_key.pem"))
  Base64.encode64(@private_key.public_encrypt(value))
end