SymmetricEncryption API

Quick Test

Before configuration or generating keys SymmetricEncryption can be used in a standalone test scenario:

# Use test encryption keys
SymmetricEncryption.cipher = SymmetricEncryption::Cipher.new(
  key:         '1234567890ABCDEF',
  iv:          '1234567890ABCDEF',
  cipher_name: 'aes-128-cbc'
)

encrypted = SymmetricEncryption.encrypt('hello world')

puts SymmetricEncryption.decrypt(encrypted)

SymmetricEncryption.encrypt

Encrypt the supplied string using Symmetric Encryption.

SymmetricEncryption.encrypt(str, random_iv: true, compress: false, type: :string)

Parameters

SymmetricEncryption.decrypt

Decrypt string previously encrypted with Symmetric Encryption.

SymmetricEncryption.decrypt(encrypted_and_encoded_string, version=nil, type=:string)

Parameters:

If the supplied string has an encryption header then the cipher matching the version number in the header will be used to decrypt the string.

When no header is present in the encrypted data, a custom Block/Proc can be supplied to determine which cipher to use to decrypt the data. see #cipher_selector=.