Skip to content

Instantly share code, notes, and snippets.

@pitluga
Created December 4, 2012 14:47
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 pitluga/4204690 to your computer and use it in GitHub Desktop.
Save pitluga/4204690 to your computer and use it in GitHub Desktop.
Monkey Patch for JRuby EzCrypto to be compatible with MRI EzCrypto
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