Module: ActiveRecordEncryption::Encryptor

Defined in:
lib/active_record_encryption/encryptor.rb,
lib/active_record_encryption/encryptor/cipher.rb

Defined Under Namespace

Classes: Cipher

Class Method Summary collapse

Class Method Details

.decrypt(value, cipher: ActiveRecordEncryption.cipher) ⇒ Object



13
14
15
16
# File 'lib/active_record_encryption/encryptor.rb', line 13

def decrypt(value, cipher: ActiveRecordEncryption.cipher)
  raise_missing_cipher_error unless cipher
  cipher.decrypt(value)
end

.encrypt(value, cipher: ActiveRecordEncryption.cipher) ⇒ Object



6
7
8
9
10
11
# File 'lib/active_record_encryption/encryptor.rb', line 6

def encrypt(value, cipher: ActiveRecordEncryption.cipher)
  raise_missing_cipher_error unless cipher

  string = value_to_string(value)
  cipher.encrypt(string)
end