Actually I just find the solution. The problem was that the PasswordDeriveByte System from C# don't create the same kind of Key/IV that the Perl CBC system (that uses openssl system). However, here is the C# code to generate de Key and IV
private void GenerateKeyIV(string strKey, byte[] bSalt, out byte[] bEn +cKey, out byte[] bEncIV) { // Extracted from http://www.jensign.com/JavaScience/dotne +t/DeriveKeyM/ // by Michel Gallant int HASHLENGTH = 16; byte[] bKey = Encoding.UTF8.GetBytes(strKey); int count = 1; int miter = 3; byte[] keymaterial = new byte[HASHLENGTH * miter]; byte[] data00 = new byte[bKey.Length + bSalt.Length]; Array.Copy(bKey, data00, bKey.Length); Array.Copy(bSalt, 0, data00, bKey.Length, bSalt.Length); MD5 md5 = new MD5CryptoServiceProvider(); byte[] result = null; byte[] hashtarget = new byte[HASHLENGTH + data00.Length]; for (int j = 0; j < miter; j++) { if (j == 0) result = data00; else { Array.Copy(result, hashtarget, result.Length); Array.Copy(data00, 0, hashtarget, result.Length, d +ata00.Length); result = hashtarget; } for (int i = 0; i < count; i++) result = md5.ComputeHash(result); Array.Copy(result, 0, keymaterial, j * HASHLENGTH, res +ult.Length); } bEncKey = new byte[32]; bEncIV = new byte[16]; Array.Copy(keymaterial, 0, bEncKey, 0, 32); Array.Copy(keymaterial, 32, bEncIV, 0, 16); }

In reply to Re^2: Encrypting a Message in C# with Rijndael and Decrypting it on Perl by zeussn
in thread Encrypting a Message in C# with Rijndael and Decrypting it on Perl by zeussn

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.