Skip to content

Instantly share code, notes, and snippets.

@jpoz
Created July 5, 2011 22:39
Show Gist options
  • Save jpoz/1066127 to your computer and use it in GitHub Desktop.
Save jpoz/1066127 to your computer and use it in GitHub Desktop.
def cipher(mode, salt, pepper, iv)
@cipher = OpenSSL::Cipher::Cipher.new('aes-128-cbc')
if mode
@cipher.encrypt
else
@cipher.decrypt
end
# @cipher.padding=1
key = Digest::SHA1.hexdigest(salt + pepper)
@cipher.key = key
@cipher.iv = iv
@cipher
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment