Module: EncryptionHandler
- Defined in:
- lib/encryptable/encryption_handler.rb
Overview
EncryptionHandler
Class Method Summary collapse
Class Method Details
.encrypt(value, key, iv, algorithm) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/encryptable/encryption_handler.rb', line 10 def self.encrypt(value, key, iv, algorithm) validate_input(value) return if value.nil? cipher = setup_cipher(key, iv, algorithm) encrypted = encrypt_value(cipher, value) Base64.encode64(encrypted).encode('utf-8') rescue OpenSSL::Cipher::CipherError => e handle_encryption_error(e) end |