Skip to content

Instantly share code, notes, and snippets.

@samullen
Created August 19, 2010 18:39
Show Gist options
  • Save samullen/538575 to your computer and use it in GitHub Desktop.
Save samullen/538575 to your computer and use it in GitHub Desktop.
Dumbed down module to show eas encoding/decoding
module Encoding
def aes_encode(string, passphrase)
c = OpenSSL::Cipher::Cipher.new("aes-256-cbc")
c.encrypt
c.key = key = Digest::SHA1.hexdigest(passphrase)
e = c.update(string)
e << c.final
end
def aes_decode(string, passphrase)
c = OpenSSL::Cipher::Cipher.new("aes-256-cbc")
c.decrypt
c.key = key = Digest::SHA1.hexdigest(passphrase)
d = c.update(string)
d << c.final
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment