The variables are strOrig (PlainText) and strKey (Passphrase) System.IO.MemoryStream ms = new System.IO.MemoryStream(); System.Security.Cryptography.RijndaelManaged rj = new System.Security.Cryptography.RijndaelManaged(); rj.Mode = System.Security.Cryptography.CipherMode.CBC; RandomNumberGenerator rng = RandomNumberGenerator.Create(); byte[] salt = new byte[8]; rng.GetBytes(salt); PasswordDeriveBytes pdb = new PasswordDeriveBytes(strKey, salt); rj.IV = pdb.GetBytes(16); rj.Key = pdb.GetBytes(32); // Debug so I can see the IV, Key, and Salt Generated string strIV = Encoding.UTF8.GetString(rj.IV); string _strKey = Encoding.UTF8.GetString(rj.Key); string strSalt = Encoding.UTF8.GetString(salt); ms.Write(Encoding.UTF8.GetBytes("Salted__"), 0, Encoding.UTF8.GetByteCount("Salted__")); ms.Write(salt, 0, salt.Length); ms.Write(rj.IV, 0, rj.IV.Length); byte[] bOrig = Encoding.UTF8.GetBytes(strOrig); System.Security.Cryptography.CryptoStream cs = new System.Security.Cryptography.CryptoStream(ms, rj.CreateEncryptor(), System.Security.Cryptography.CryptoStreamMode.Write); cs.Write(bOrig, 0, bOrig.Length); cs.FlushFinalBlock(); string bResult = Convert.ToBase64String(ms.ToArray()); bResult = bResult.Remove(0, 10); ms.Flush(); return bResult; #### #!/opt/local/bin/perl -w use IO::Socket; use IO::Handle; use MIME::Base64; use Data::Dumper; use POSIX; use Getopt::Long; use strict; require Crypt::CBC; my $msg = "Message_Generated_in_C#"; my $enc_key = "same_as_in_c#_strKey"; my $enc_alg = "Rijndael"; my $cipher = Crypt::CBC->new({ 'key' => $enc_key, 'cipher' => $enc_alg, }); my $base64_decoded_msg = decode_base64($msg); my $decrypted_msg = $cipher->decrypt($base64_decoded_msg); // This is for debug print STDERR " Salt:\n"; &hex_dump($cipher->salt()); print STDERR " Key:\n"; &hex_dump($cipher->key()); print STDERR " IV:\n"; &hex_dump($cipher->iv()); print STDERR " PassPhrase:\n"; &hex_dump($cipher->passphrase()); print STDERR " Block Size: " . $cipher->blocksize() ."\n", " Key Size: " . $cipher->keysize(). "\n\n"; print "$decrypted_msg\n"; // Function for debug sub hex_dump() { my $data = shift; my @chars = split //, $data; my $ctr = 0; my $ascii_str = ''; for my $char (@chars) { if ($ctr % 16 == 0) { print STDERR " $ascii_str\n" if $ascii_str; printf STDERR " 0x%.4x: ", $ctr; $ascii_str = ''; } printf STDERR "%.2x", ord($char); if ((($ctr+1) % 2 == 0) and ($ctr % 16 != 0)) { print STDERR ' '; } if ($char =~ /[^\x20-\x7e]/) { $ascii_str .= '.'; } else { $ascii_str .= $char; } $ctr++; } if ($ascii_str) { my $remainder = 1; if ($ctr % 16 != 0) { $remainder = 16 - $ctr % 16; if ($remainder % 2 == 0) { $remainder = 2*$remainder + int($remainder/2) + 1; } else { $remainder = 2*$remainder + int($remainder/2) + 2; } } print STDERR ' 'x$remainder, $ascii_str; } print STDERR "\n"; return; }