Please put <c>...</c> around your long data line! (And please include a newline within those tags.)


The data size doesn't jive.

The cipher text, once base64 decoded, is 576 ( 72*8 ) bytes long.
Your plain text is 550 ( 68*8+6 ) bytes long.
Your padded plain text is 552 ( 69*8 ) bytes long.
The IV is 8 bytes long.
There are 16 ( 576-(552+8) ) unaccounted bytes

Unless the CRLF is used for line endings.

The cipher text, once base64 decoded, is 576 ( 72*8 ) bytes long.
Your plain text is 560 ( 70*8+0 ) bytes long.
Your padded plain text is 568 ( 71*8 ) bytes long.
The IV is 8 bytes long.
There are 0 ( 576-(568+8) ) unaccounted bytes

At least your Java code outputs as many bytes as expected.


The following should produce the plain text.

use strict; use warnings; use Crypt::CBC qw( ); use List::MoreUtils qw( apply ); use MIME::Base64 qw( decode_base64 ); my $key = 'Abcdefghijklmnopqrstuvwxyz1234567890'; my $ctext = decode_base64(apply { s/\s//g } <<'__EOI__'); mGWcw1XJV3ooXbGvzBuShOA2gwcUnW11NZnHm1Nm 8JQktRSoaAKl369jL8ZLnJNF71I5ctZq8wGGtfov iLj6PoXZWlzcasgBBUMefjGa0h+L53/VODmqCDaL 6jnZycB5VTngY5gt/9VpYxVW0KB5yR0TJrhHQa02 Vgn1I9ePtmbJfOkALXZPwY0H8MDULkzIYX409iSm 6zgu76UvW81qpJiakFDi9jmIbL4NVWYRlVR1xLRC HiM8X8q0yCT1ZQO9HJE8vHc/jKdEOi8QGNyAOtdd ku7Ikg4Pzwpk7g+R/TOCx7Q8xDKbV93sFHu1s3co pZrpCcNmd8Oy1CFazZ5FweWwsFqfgxMqopMrtaG6 Qc1J7cB3fYpI2RDN6xbAJ8HPZWGdOQsobopv+Czt GFuzVaVfwz8YXrLEXlbRFfv8Cpt8Q320NAAhwjFj eEUMyPCpzVZaBske4NDJ++7JomijlS8H8cHmmD6P Hbopy41W8BF9tsV9nqXgYeiVna98MNTEkyToyP/Z kBhGYJcutv3s9pG7SydwuKCxCd+Dugusnu8lM10/ 5UmGJ7YTGFCJvtfpXR9XoMCQ++eT4/YN9kZlim+2 bkjh01xPnG9r7PChWAVxpUVjOisGlZKrPV6tQRPU qwQ0die7XienUt5e+jACACGMqXWA4O8P5sg/iT3w Z2+dDIQiUnxCIATKn74/B8V9PDdtHnr5XOP5KPKK aYcz/gXt1Q6WkWawUIoLvCkobkm5o7MXeAiJCtet emfA86bV __EOI__ my $blksz = 8; # Chicken-egg UI problem with Crypt::CBC. my $iv = substr($ctext, 0, $blksz, ''); my $cipher = Crypt::CBC->new( -cipher => 'Blowfish', -key => $key, -header => 'none', -iv => $iv, ); binmode(STDOUT); print($cipher->decrypt($ctext));

...But it doesn't. I'll have to study how the key is used by both libraries. Or maybe it's some byte ordering problem? But I don't think so from what I've seen.


Your padding method could be problematic. You use
byte fill = (byte)mod;           while (i < len) { inBuf[i++] = (byte)fill; }
but Crypt::CBC expects
byte fill = (byte)(len-origLen); while (i < len) { inBuf[i++] = (byte)fill; }


In reply to Re^3: Decrypting BlowfishNET (was Re^11: line by line Encryption ...) by ikegami
in thread line by line Encryption fun with Crypt::CBC and Rijndael? File Ownership issues? by hmbscully

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.