Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8696707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:20:15+00:00 2026-06-13T01:20:15+00:00

I cannot get Perl and Ruby to agree on CBC AES: Perl use Crypt::CBC;

  • 0

I cannot get Perl and Ruby to agree on CBC AES:

Perl

use Crypt::CBC;
use MIME::Base64::Perl;

my $cipher = Crypt::CBC->new(
        -key         => 'd2cb415e067c7b13',
        -iv          => 'e36dc751d0433f05', #random 16chars!!!!!! shold NOT repeat between requests
        -cipher      => 'OpenSSL::AES',     #this is same as Rijndael
        -literal_key => 1,        
        -header      => "none",
        -keysize     => 16
  );  

$encypted = $cipher->encrypt("a really really long long text has differrent results???");
$base64 = encode_base64($encypted);

print("Ciphertext(b64): $base64");

$de_base64 = decode_base64($base64);
$decrypted = $cipher->decrypt($de_base64);
$c = $cipher->finish;

Ciphertext(b64): qz4eSQaFkQUkDOyJSbZf5W03HoldwtgvTLq0yJFRViKJnytf3PVSCGW2CYDjO+tRqV20oxeB2VPa
7NqN1TDSNQ==

there’s a newline after the 2VPa section and another at the end

Ruby

require 'openssl'
require 'digest/sha2'
require 'base64'

message = "a really really long long text has differrent results???" 
cipher = OpenSSL::Cipher.new('aes-128-cbc')

# digest the key, iv and hmac_key so we have 16-byte length 
# also, it looks more of a funky password
# prepare cipher
cipher.encrypt
cipher.key = aes_key = "d2cb415e067c7b13"
cipher.iv = aes_iv = "e36dc751d0433f05"


encrypted = cipher.update(message)
encrypted << cipher.final()
b64_encoded = Base64.encode64(encrypted).encode('utf-8') #strict_encode64 guarantees no newlines, encode64 is default

puts "AES Key        : '#{aes_key}'"
puts "AES IV         : '#{aes_iv}'"
puts "Ciphertext(b64): '#{b64_encoded}'"

Ciphertext(b64): ‘qz4eSQaFkQUkDOyJSbZf5W03HoldwtgvTLq0yJFRViKJnytf3PVSCGW2CYDj
O+tRqV20oxeB2VPa7NqN1TDSNQ==
‘

Note the newlines chars after CYDj and after ==

I’ve seen the following: Perl & Ruby exchange AES encrypted information, but I’m not using padding=0

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T01:20:16+00:00Added an answer on June 13, 2026 at 1:20 am

    Newlines are not significant in Base64. You got exactly the same result from both languages.

    While there should be absolutely no reason to do so, you could make the Perl version return the same string as the Ruby version as follows:

    $base64 = encode_base64($encypted, '');
    $base64 =~ s/\G.{60}\K/\n/sg;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I cannot get this to work. #!/usr/bin/perl -w use strict; use CGI::Carp qw(fatalsToBrowser warningsToBrowser);
I cannot get in-place editing Perl one-liners running under ActivePerl to work unless I
When you run perl -e "Bla->new" , you get this well-known error: Can't locate
I'm writing a test for an FTP server in Perl, but I cannot get
This is my first attempt to inline Java code in Perl. We cannot use
I'm totally new to Perl, and I need to get a small find and
I cannot get my Wordpress theme to randomise the posts I'm displaying in the
I cannot get my Spring web app to find my scripts. I have the
I cannot get this function to fire off... I'm thinking I need a fresh
I cannot get my SID working ... <?php session_start(); // Or maybe pass along

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.