I am trying to convert this PHP code to Ruby but the result is not the same. What am I doing wrong?
$iv = str_repeat('0', 16);
$passphrase = str_repeat('0', 32);
$encrypted = openssl_encrypt('Hello', 'AES-256-CBC', $passphrase, 0, $iv);
echo $encrypted; // => lfbW8JcPq6dkEnmY0hG7Vw==
cipher = OpenSSL::Cipher.new('AES-256-CBC').encrypt
cipher.iv = '0' * 16
cipher.key = '0' * 32
encrypted = cipher.update('Hello') + cipher.final
puts encrypted # => \x95\xF6\xD6\xF0\x97\x0F\xAB\xA7d\x12y\x98\xD2\x11\xBBW
I suggest you use Base64#encode64 to get the same result as in your php example.
require 'Base64'
puts Base64.encode64(encrypted) # => lfbW8JcPq6dkEnmY0hG7Vw==