Re: Encrypting byte array
From: Alek Davis (alek_DOT_davis_AT_intel_DOT_com)
Date: 03/27/03
- Next message: Alek Davis: "Re: Stream encryption not working"
- Previous message: shahzad: "RSA encryption and decryption!!!!"
- In reply to: Etienne Charland: "Encrypting byte array"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
From: "Alek Davis" <alek_DOT_davis_AT_intel_DOT_com> Date: Thu, 27 Mar 2003 09:47:58 -0800
Etienne,
> If not ... how do I know the length of the data during decryption?
I assume that you are trying to figure out the length of decrypted data. The
answer is: you do not know (before you start decrypting). So how many bytes
do you need to allocate? Well, since decrypted value should be shorter than
encrypted value, you can simply allocate the same number of bytes as in
encrypted value. When you call the decryption routine (CryptoStream.Read),
it will return the number of bytes which were actually decrypted, so you can
simply remove unused bytes after completing decryption. Check the example at
http://www.obviex.com/Samples/Encryption.aspx; it may give you some
additional info.
-- Alek
"Etienne Charland" <mystery@golden.net> wrote in message
news:#Wtf1Rx8CHA.2368@TK2MSFTNGP10.phx.gbl...
> I need a function that encrypts (another one to decrypt) a byte array, and
> returns the encrypted byte array. I've done it using CryptoStream, but
this
> gives very poor performances since I convert the bytes into a stream,
> encrypt with CryptoStream (wich converts to byte arrays internally), and
> then convert the result stream into a byte array. Have anyone done such a
> function that works directly with ICryptoTransform to convert blocks of
> data? If yes, could I have a link? If not, I have another question. Since
> block sizes are fixed (16 bytes for Rijndael), how do I know the length of
> the data during decryption? When encrypting, I have to add padding, but
> then, on decryption, I don't know what is the data and what is the
> padding...
>
> Thank you very much for your help
>
> Etienne
>
>
- Next message: Alek Davis: "Re: Stream encryption not working"
- Previous message: shahzad: "RSA encryption and decryption!!!!"
- In reply to: Etienne Charland: "Encrypting byte array"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|