Re: RijndaelManaged decryption leaves strange characters
From: Alek Davis (alek_xDOTx_davis_xATx_intel_xDOTx_com)
Date: 02/12/04
- Next message: Bill: "web service trying to access registry"
- Previous message: dm_dal: "Re: RijndaelManaged decryption leaves strange characters"
- In reply to: dm_dal: "RijndaelManaged decryption leaves strange characters"
- Next in thread: dm_dal: "Re: RijndaelManaged decryption leaves strange characters"
- Reply: dm_dal: "Re: RijndaelManaged decryption leaves strange characters"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Thu, 12 Feb 2004 10:23:22 -0800
David,
When you convert the array of decrypted bytes to string, make sure that you
only include the number of actually decrypted bytes, not the whole array. I
don't know how you do this, but a typical problem is that when you allocate
an array of bytes to hold decrypted data, you do not know in advance what
the size of this array should be (since encrypted data are longer than plain
text for Rijndael). So acceptable practice is to allocate the array of the
same size as encrypted array, but when the decryption is done and you know
how many plain text bytes were returned, only convert these bytes to string.
Alek
"dm_dal" <REMOVE_THIS.dmy75252@yahoo.com> wrote in message
news:OZHKGrY8DHA.2924@tk2msftngp13.phx.gbl...
> We've got an encryption/decryption assembly that we built in-house that
uses
> the RijndaelManaged to encrypt/decrypt certain pieces of sensative data
that
> is stored in a SQL Server 2K database.
>
> Basically here's the flow:
>
> Encrypt:
> Encrypt the data using RijndaelManaged in CBC Mode.
> Store the Base64Encoded cipher text in the DB (column is varchar(80))
>
> Decrypt:
> Pull Base64Encoded string from DB and Convert.FromBase64String
> Decrypt using RijndaelManaged in CBC Mode
> return Encoding.UTF8.GetString( unencrypted byte[] );
>
> When viewing the decrypted text in a web form, the display is correct.
> However, when viewed in a WindowsForm DataGrid, the decrypted string is
> shown with trailing "|||||||" characters. When you click in the cell to
> edit the text, the trailing characters disappear, when you leave the cell,
> they reappear. If you actually do an edit on the cells data, the trailing
> characters disappear and don't return when you leave the cell.
>
> Do you suppose this extra character data is the result of the UTF8
encoding?
>
> David
>
>
- Next message: Bill: "web service trying to access registry"
- Previous message: dm_dal: "Re: RijndaelManaged decryption leaves strange characters"
- In reply to: dm_dal: "RijndaelManaged decryption leaves strange characters"
- Next in thread: dm_dal: "Re: RijndaelManaged decryption leaves strange characters"
- Reply: dm_dal: "Re: RijndaelManaged decryption leaves strange characters"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|