Skip to content

Instantly share code, notes, and snippets.

@mattetti
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattetti/97adf09df58b969943d4 to your computer and use it in GitHub Desktop.
Save mattetti/97adf09df58b969943d4 to your computer and use it in GitHub Desktop.
crypt_secret = key_generator.generate_key("signed encrypted cookie")
encryptor = ActiveSupport::MessageEncryptor.new(secret, crypt_secret)
encrypted_message = encryptor.encrypt_and_sign({msg: "hello world"})
encryptor.decrypt_and_verify(encrypted_message)
# => {:msg => "hello world"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment