Byte array to string and back - newbie question
popsovy_at_rusmex.com
Date: 02/05/04
- Next message: Mattias Sjögren: "Re: Byte array to string and back - newbie question"
- Previous message: Soul: "Re: Q: User Control & Form Authentication"
- Next in thread: Mattias Sjögren: "Re: Byte array to string and back - newbie question"
- Reply: Mattias Sjögren: "Re: Byte array to string and back - newbie question"
- Reply: Craig: "Re: Byte array to string and back - newbie question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Wed, 4 Feb 2004 21:06:06 -0800
Hi,
I am trying to implement DES algorithm as described in the Microsoft article at
http://msdn.microsoft.com/library/en-us/dnnetsec/html/SecNetHT10.asp.
The problem is that I need to save the data in the database as String, and for that I have to convet from Byte array to string and back.
When I cast a byte array into a string and then back to a byte array, I don't get the same array. For example:
Dim SecretText As Byte()
Dim SecretText1 As Byte()
Dim Text as string
.....
SecretText = enc.Encrypt(Data, Key, Vector) 'returns Byte Array
Text = Encoding.ASCII.GetString(SecretText) 'convert to string in order to save into the DB
....
....
....
SecretText1 = Encoding.ASCII.GetBytes(Text) 'prepare for decryption routine
At the end, SecretText1 does NOT equal to SecretText, and I want it to be. How should I do the conversion correctly?
Thanks!!!
Zhenya
http://www.rusmex.com
- Next message: Mattias Sjögren: "Re: Byte array to string and back - newbie question"
- Previous message: Soul: "Re: Q: User Control & Form Authentication"
- Next in thread: Mattias Sjögren: "Re: Byte array to string and back - newbie question"
- Reply: Mattias Sjögren: "Re: Byte array to string and back - newbie question"
- Reply: Craig: "Re: Byte array to string and back - newbie question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|