Module: PWS::Encryptor
- Defined in:
- lib/pws/encryptor.rb
Overview
This encryptor class wraps around openssl to simplify en/decryption using AES 256 CBC Please note: Failed en/decryptions will raise errors
Constant Summary collapse
- CIPHER =
'aes-256-cbc'
Class Method Summary collapse
- .decrypt(encrypted_data, options = {}) ⇒ Object
- .encrypt(unecrypted_data, options = {}) ⇒ Object
- .random_iv ⇒ Object
Class Method Details
.decrypt(encrypted_data, options = {}) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/pws/encryptor.rb', line 10 def decrypt(encrypted_data, = {}) crypt( :decrypt, encrypted_data, [:key], [:iv], ) end |
.encrypt(unecrypted_data, options = {}) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/pws/encryptor.rb', line 19 def encrypt(unecrypted_data, = {}) crypt( :encrypt, unecrypted_data, [:key], [:iv], ) end |
.random_iv ⇒ Object
28 29 30 |
# File 'lib/pws/encryptor.rb', line 28 def random_iv OpenSSL::Cipher.new(CIPHER).random_iv end |