Re: Encrypting byte array

From: Alek Davis (alek_DOT_davis_AT_intel_DOT_com)
Date: 03/27/03


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
>
>



Relevant Pages

  • Re: About padding with files in AES
    ... the system which encrypts and the system which decrypts. ... padding can be ... A block cipher such as AES ... "Upon decryption, the decrypting system just needs to look at ...
    (sci.crypt)
  • Encrypting byte array
    ... I need a function that encrypts a byte array, ... returns the encrypted byte array. ... I've done it using CryptoStream, ... then, on decryption, I don't know what is the data and what is the ...
    (microsoft.public.dotnet.security)
  • Re: Encrypting byte array
    ... > I need a function that encrypts a byte array, ... > returns the encrypted byte array. ... > block sizes are fixed, how do I know the length of ... > then, on decryption, I don't know what is the data and what is the ...
    (microsoft.public.dotnet.security)
  • decrypting request
    ... I am looking for help with decryption analysis some text documents. ... I have an application that encrypts the documents for storage, ... George Pickard ...
    (sci.crypt)
  • Re: In Search for the Proper Crypto System
    ... >> text always encrypts to the same ciphertext, then I can just quiz the ... transmitting the plain text would not be practical for the ... > How about publishing the plain text for later download and decryption? ...
    (sci.crypt)