Type:
Class
Constants:
OpenSSLCipherError : OpenSSL::Cipher::CipherError

MessageEncryptor is a simple way to encrypt values which get stored somewhere you don't trust.

The cipher text and initialization vector are base64 encoded and returned to you.

This can be used in situations similar to the MessageVerifier, but where you don't want users to be able to determine the value of the payload.

salt  = SecureRandom.random_bytes(64)
key   = ActiveSupport::KeyGenerator.new('password').generate_key(salt) # => "\x89\xE0\x156\xAC..."
crypt = ActiveSupport::MessageEncryptor.new(key)                       # => #<ActiveSupport::MessageEncryptor ...>
encrypted_data = crypt.encrypt_and_sign('my secret data')              # => "NlFBTTMwOUV5UlA1QlNEN2xkY2d6eThYWWh..."
crypt.decrypt_and_verify(encrypted_data)                               # => "my secret data"
decrypt_and_verify

decrypt_and_verify(value) Instance Public methods Decrypt and verify a message

2015-06-20 00:00:00
encrypt_and_sign

encrypt_and_sign(value) Instance Public methods Encrypt and sign a message.

2015-06-20 00:00:00
new

new(secret, *signature_key_or_options) Class Public methods Initialize a new

2015-06-20 00:00:00