Class: Encryptable::Cipher
- Inherits:
-
Object
- Object
- Encryptable::Cipher
- Defined in:
- lib/encryptable/cipher.rb
Overview
This class handles encryption and decryption using AES-256-CBC algorithm.
Constant Summary collapse
- ALGORITHM =
'AES-256-CBC'
Instance Method Summary collapse
- #decrypt(value) ⇒ Object
- #encrypt(value) ⇒ Object
-
#initialize(key:, iv:) ⇒ Cipher
constructor
A new instance of Cipher.
Constructor Details
#initialize(key:, iv:) ⇒ Cipher
16 17 18 19 20 21 |
# File 'lib/encryptable/cipher.rb', line 16 def initialize(key:, iv:) validate_string_inputs!(key, iv) decode_key_and_iv!(key, iv) validate_lengths! derive_key_and_iv! end |
Instance Method Details
#decrypt(value) ⇒ Object
27 28 29 |
# File 'lib/encryptable/cipher.rb', line 27 def decrypt(value) DecryptionHandler.decrypt(value, @key, @iv, ALGORITHM) end |
#encrypt(value) ⇒ Object
23 24 25 |
# File 'lib/encryptable/cipher.rb', line 23 def encrypt(value) EncryptionHandler.encrypt(value, @key, @iv, ALGORITHM) end |