Hello all,
I have been looking all over for a method to take an encrypted string produced by the RijndaelManaged class (in .net framework) and decrypt it in perl.
I have the IV and Key and the method that the string was built, but I don't know (and haven't looked into the .net source as of yet) how the class handles the iv and key.
For Example:
use strict;
use Crypt::Rijndael;
my $key = "qwertyuiopllkjhgfdsa";
my $iv = “mnbvcxzasdfghjkloiuy";
my $rcipher = Crypt::Rijndael->new ($key, Crypt::Rijndael::MODE_CBC())
+;
$rcipher->set_iv($iv);
my $encrypt_string = “STRING_PULLED_FROM_FILE”;
my $plain_text = $rcipher->decrypt($encrypt_string);
Now,
The above does not work because it is lacking the information that I need, in this case the method to covert the IV to a block size of 16 bytes and the method to covert the Key to the same method utilized by the RijndaelManaged class.
Currently, I use Crypt::Rijndael and/or Crypt::CBC (both decrypt and encrypt) in other perl code with the following (based on my example above).
use strict;
use Crypt::Rijndael;
use Digest::MD5 qw(md5 md5_hex);
my $key = "qwertyuiopllkjhgfdsa";
my $iv = “mnbvcxzasdfghjkloiuy";
$key = md5_hex $key;
$iv = md5 $iv;
my $rcipher = Crypt::Rijndael->new ($key, Crypt::Rijndael::MODE_CBC())
+;
$rcipher->set_iv($iv);
my $data = “PLAINTEXT_TOBE_ENC”;
my $encrypt_string = $rcipher->encrypt($data);
my $plain_text = $rcipher->decrypt($encrypt_string);
Does anyone know the correct method to do the same with a string encrypted with RijndaelManaged?
I can provide more specific code if need, please let me know if you can help.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.