Click here to Skip to main content
15,910,886 members
Home / Discussions / C#
   

C#

 
QuestionTesting for current PictureBox.Image Pin
kanchoette9-Jul-09 3:16
kanchoette9-Jul-09 3:16 
AnswerRe: Testing for current PictureBox.Image Pin
Christian Graus9-Jul-09 3:18
protectorChristian Graus9-Jul-09 3:18 
AnswerRe: Testing for current PictureBox.Image Pin
Sun Rays9-Jul-09 3:39
Sun Rays9-Jul-09 3:39 
GeneralRe: Testing for current PictureBox.Image Pin
Christian Graus9-Jul-09 3:54
protectorChristian Graus9-Jul-09 3:54 
GeneralRe: Testing for current PictureBox.Image Pin
kanchoette9-Jul-09 4:27
kanchoette9-Jul-09 4:27 
GeneralRe: Testing for current PictureBox.Image Pin
Luc Pattyn9-Jul-09 9:31
sitebuilderLuc Pattyn9-Jul-09 9:31 
AnswerRe: Testing for current PictureBox.Image Pin
0x3c09-Jul-09 5:40
0x3c09-Jul-09 5:40 
QuestionC# Rijndael Encrypt and Pel Crypt::CBC Pin
DanielLC9-Jul-09 3:13
DanielLC9-Jul-09 3:13 
Hi,

I'm trying to encrypt a string in c# that would be decrypted with perl. The problem is that in the perl script there is not IV specified so, when I encrypt the result is not readable be the perl decryptor.

Is there any workaround to know who perl auto generate the IV (I suppose that's what it does) ?


C# Code to Encrypt :

        private string strCryptoMessage(string strOrig, string strKey)
        {
            System.Security.Cryptography.RijndaelManaged rj = new System.Security.Cryptography.RijndaelManaged();
            rj.Mode = System.Security.Cryptography.CipherMode.CBC;
            rj.Key = Encoding.UTF8.GetBytes(strKey);

            byte[] bOrig = Encoding.UTF8.GetBytes(strOrig);

            System.IO.MemoryStream ms = new System.IO.MemoryStream();

            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());
            ms.Flush();

            
            return bResult;
        }


Perl Code To Encrypt :

#!/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_TO_ENCRYPT";
my $enc_key = "SAME_AS_strKey";
my $enc_alg = "Rijndael";

my $cipher = Crypt::CBC->new({
        'key'    => $enc_key,
        'cipher' => $enc_alg,
    });

    my $encrypted_msg = $cipher->encrypt($msg);
    print "$msg\n";

    my $encoded_msg = encode_base64($encrypted_msg, '');
    print "$encoded_msg\n";


Both should generate the same result, but I think that the perl Crypt::CBC generate the IV code using the key in some way.
QuestionGraphics.DrawImageUnscaled blurry Pin
Huisheng Chen9-Jul-09 3:02
Huisheng Chen9-Jul-09 3:02 
AnswerRe: Graphics.DrawImageUnscaled blurry Pin
Christian Graus9-Jul-09 3:17
protectorChristian Graus9-Jul-09 3:17 
GeneralRe: Graphics.DrawImageUnscaled blurry Pin
Huisheng Chen9-Jul-09 3:53
Huisheng Chen9-Jul-09 3:53 
QuestionToUnicodeEx and dead keys inside system wide hooks Pin
RevengerPT9-Jul-09 2:52
RevengerPT9-Jul-09 2:52 
Questioncash register. Pin
solomonope9-Jul-09 2:03
solomonope9-Jul-09 2:03 
AnswerRe: cash register. Pin
Christian Graus9-Jul-09 2:13
protectorChristian Graus9-Jul-09 2:13 
GeneralRe: cash register. Pin
solomonope9-Jul-09 3:43
solomonope9-Jul-09 3:43 
AnswerRe: cash register. Pin
Rajesh R Subramanian9-Jul-09 3:17
professionalRajesh R Subramanian9-Jul-09 3:17 
GeneralRe: cash register. Pin
Manas Bhardwaj9-Jul-09 3:28
professionalManas Bhardwaj9-Jul-09 3:28 
GeneralRe: cash register. Pin
solomonope9-Jul-09 3:37
solomonope9-Jul-09 3:37 
GeneralRe: cash register. Pin
OriginalGriff9-Jul-09 4:02
mveOriginalGriff9-Jul-09 4:02 
GeneralRe: cash register. Pin
Rajesh R Subramanian9-Jul-09 4:13
professionalRajesh R Subramanian9-Jul-09 4:13 
QuestionProblem in viewing image in multi user environment Pin
Khawar Abbas19-Jul-09 2:01
Khawar Abbas19-Jul-09 2:01 
AnswerRe: Problem in viewing image in multi user environment Pin
Christian Graus9-Jul-09 2:14
protectorChristian Graus9-Jul-09 2:14 
GeneralRe: Problem in viewing image in multi user environment Pin
Khawar Abbas19-Jul-09 2:19
Khawar Abbas19-Jul-09 2:19 
GeneralRe: Problem in viewing image in multi user environment Pin
Christian Graus9-Jul-09 2:36
protectorChristian Graus9-Jul-09 2:36 
GeneralRe: Problem in viewing image in multi user environment Pin
Khawar Abbas19-Jul-09 2:41
Khawar Abbas19-Jul-09 2:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.