Created
April 24, 2017 18:44
-
-
Save scottwater/ebe6fd1df2955cae336cc957ff28ca20 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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