require 'openssl' openssl_cipher = ::OpenSSL::Cipher.new('aes-128-cbc') openssl_cipher.encrypt openssl_cipher.key = '1234567890ABCDEF1234567890ABCDEF' result = openssl_cipher.update('Hello World') result << openssl_cipher.final puts result.unpack('H*') # jruby 1.7.0.RC1 (1.9.3p203) 2012-09-25 8e849de on Java HotSpot(TM) 64-Bit Server VM 1.6.0_35-b10-428-11M3811 [darwin-x86_64] # => 9dc9ebb434bc421326664c038bb4271d # # ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0] # => b597b74f1de1f19a83d901a6fdb40643 # # ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin12.2.0] # => b597b74f1de1f19a83d901a6fdb40643 # # jruby 1.6.8 (ruby-1.8.7-p357) (2012-09-18 1772b40) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_35) [darwin-x86_64-java] # => 9dc9ebb434bc421326664c038bb4271d # # jruby 1.6.5 (ruby-1.8.7-p330) (2011-10-25 9dcd388) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_35) [darwin-x86_64-java] # => 9dc9ebb434bc421326664c038bb4271d