Module: RSwim::Encryption
- Defined in:
- lib/rswim/encryption.rb
Class Method Summary collapse
Class Method Details
.decrypt(cipher_text, salt) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/rswim/encryption.rb', line 13 def decrypt(cipher_text, salt) decipher.iv = salt = decipher.update(cipher_text) + decipher.final .force_encoding('UTF-8') rescue StandardError => e raise Error, "Failed to decrypt: #{e.}" end |
.encrypt(message) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/rswim/encryption.rb', line 4 def encrypt() = .dup.force_encoding('UTF-8') salt = cipher.random_iv cipher_text = cipher.update() + cipher.final [cipher_text, salt] rescue StandardError => e raise Error, "Failed to encrypt: #{e.}" end |