From: "David D." Date: 2013-05-19T23:55:42+09:00 Subject: why first 16 bytes are wrong with ruby openssl aes 128 cbc ? I use openssl in ruby and openssl in bash, but the first 16 bytes with ruby/openssl are wrong, why ? (ruby version : 1.8.7) for exemple : with ruby openssl 77 70 30 21 30 30 80 3d 30 31 f1 30 30 30 31 de wrong bytes ff 36 90 e2 3d ff ff ff ff ff ff ff ff ff ff ff good bytes ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff good bytes ********************good bytes****************** good bytes with bash openssl 47 40 00 11 00 00 b0 0d 00 01 c1 00 00 00 01 ef ff 36 90 e2 3d ff ff ff ff ff ff ff ff ff ff ff same bytes that ruby ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff same bytes that ruby *******************a lot of bytes*************** same bytes that ruby ruby code : require 'openssl' c = OpenSSL::Cipher::Cipher.new("aes-128-cbc") c.decrypt c.key = "\177\373\2002\337\363:\357\232\251.\232\311b9\323" c.iv = "00000000000000000000000000000001" data = File.read("/tmp/file_crypt") d = c.update(data) d << c.final file = File.open("/tmp/file_decrypt_ruby", "w") file.write(d) file.close bash code : openssl aes-128-cbc -d -in /tmp/file_crypt -out /tmp/file_decrypt_bash -nosalt -iv 00000000000000000000000000000001 -K 7ffb8032dff33aef9aa92e9ac96239d3 Thank you. -- Posted via http://www.ruby-forum.com/.