Skip to content

Instantly share code, notes, and snippets.

@dimitrisdovinos
Created February 25, 2020 19:25
Show Gist options
  • Save dimitrisdovinos/b2789f24c16853563ffc39ceffe57f23 to your computer and use it in GitHub Desktop.
Save dimitrisdovinos/b2789f24c16853563ffc39ceffe57f23 to your computer and use it in GitHub Desktop.
require 'openssl'
require 'base64'
aes = OpenSSL::Cipher.new("AES-256-CBC")
aes.encrypt
aes.key = Base64.decode64("4VZS/oCY73fTENgF8LyLq00B+bsXEHLlAFpRhoDXTKc=")
aes.iv = OpenSSL::Cipher.new("AES-256-CBC").random_iv
cipher = aes.update("I'm scared if I stop all at once, the cumulative hangover will literally kill me.")
cipher << aes.final
Base64.encode64(cipher)
# "Xfu+6jKYygwB6GlIj6zqL+Q0r3zBMo/zoAtTapREjFOCqb3+oaySCxx4Y8fV\nDg7OfUL0YBSAXzPkbV7qpqViVBcjfX9phao16CCxOObFGTXrXGgEmdxwvO85\ngESN/r/d\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment