SymmetricEncryption API

Quick Test

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

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

encrypted = SymmetricEncryption.encrypt('hello world')

puts SymmetricEncryption.decrypt(encrypted)


Encrypt the supplied string using Symmetric Encryption.

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



Decrypt string previously encrypted with Symmetric Encryption.

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


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=.