Skip to content

Instantly share code, notes, and snippets.

@scottwater
Created April 24, 2017 18:44
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 scottwater/ebe6fd1df2955cae336cc957ff28ca20 to your computer and use it in GitHub Desktop.
Save scottwater/ebe6fd1df2955cae336cc957ff28ca20 to your computer and use it in GitHub Desktop.
module Keen
class AESHelperOld
def self.aes256_encrypt(key, plaintext, iv = nil)
puts 'IN DA MONKEY PATCH!'
padded_key = key
aes = OpenSSL::Cipher::AES.new(256, :CBC)
aes.encrypt
aes.key = padded_key
aes.iv = iv unless iv.nil?
iv ||= aes.random_iv
encrypted = aes.update(plaintext) + aes.final
hexlify(iv) + hexlify(encrypted)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment