Class: EncryptedField::PolicyWithoutIV

Inherits:
BasePolicy
  • Object
show all
Defined in:
lib/encrypted-field/policy_without_iv.rb

Overview

EncryptedField::PolicyWithoutIV all the logic required to encrypt/decrypt data using symmetric encryption.

Instance Attribute Summary

Attributes inherited from BasePolicy

#algorithm, #options

Instance Method Summary collapse

Methods inherited from BasePolicy

#initialize, #prefix_with_policy_name?

Constructor Details

This class inherits a constructor from EncryptedField::BasePolicy

Instance Method Details

#decrypt(encrypted_str) ⇒ Object



15
16
17
18
19
# File 'lib/encrypted-field/policy_without_iv.rb', line 15

def decrypt(encrypted_str)
  cipher = create_cipher.decrypt
  cipher.key = secret_key
  cipher.update(decode_payload(encrypted_str)) << cipher.final
end

#encrypt(str) ⇒ Object



9
10
11
12
13
# File 'lib/encrypted-field/policy_without_iv.rb', line 9

def encrypt(str)
  cipher = create_cipher.encrypt
  cipher.key = secret_key
  encode_payload(cipher.update(str) << cipher.final)
end