Skip to content

Instantly share code, notes, and snippets.

@qmx
Created June 29, 2010 04:31
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 qmx/cb0450e5b2cb714a0ce8 to your computer and use it in GitHub Desktop.
Save qmx/cb0450e5b2cb714a0ce8 to your computer and use it in GitHub Desktop.
# pure-ruby-aes (as openssl isn't ready on ir, afaik)
# ir -Sgem install ruby-aes-normal
require 'ruby-aes'
require 'yaml'
KEY="0"*32
IV="0"*32
# mine is several times bigger than this (20x)
# works flawlessly on small strings
original_data = {:some => [{:random => "hash"},{:random => "hash"}]}.to_yaml
crypto_data = Aes.encrypt_buffer(256, 'CBC', KEY, IV, original_data)
# it will break here, as ruby-aes will try to size the buffer for breaking it on chunks
clear_data = Aes.decrypt_buffer(256, 'CBC', KEY, IV, crypto_data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment