Created
December 4, 2012 14:47
-
-
Save pitluga/4204690 to your computer and use it in GitHub Desktop.
Monkey Patch for JRuby EzCrypto to be compatible with MRI EzCrypto
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
EzCrypto::CipherWrapper.class_eval do | |
def initialize(key,target,mode,algorithm) | |
@cipher = OpenSSL::Cipher::Cipher.new(algorithm) | |
if mode | |
@cipher.encrypt | |
else | |
@cipher.decrypt | |
end | |
@cipher.key=key.raw | |
# ==== fix start ==== | |
# | |
# JRuby and MRI use different | |
# default IVs for AES CBC and unfortunately ezcrypto doesn't | |
# expplicitly set one | |
@cipher.iv="\0"*16 | |
# ==== fix end ==== | |
@cipher.padding=1 | |
@target=target | |
@finished=false | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment