Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cryptography problem returning the encripted value and decripting

Status
Not open for further replies.

HebieBug

Programmer
Joined
Jan 8, 2001
Messages
354
Location
JP
Have got a slight problem.
what I do is encript a string and then produce a UTF8 value. To then decript was planning on taking the UTF8 value and converting it into a byte array to then toss it in for decription.
The bit array takes the encripted value and breaks it up without a problem
The issue is that when I get the UTF8 value and attempt to put it back into a bit array it will not accept any value higher then 127 (ASCII limit). It then procedes to skip over that value and continue setting up the array.
Anyone got any ideas on this one??

--> code on how I bring the value into UTF8 format -->
'write plaintext bytes to crypto stream
Dim plainbytes() As Byte = Encoding.UTF8.GetBytes(m_text)
cs.Write(plainbytes, 0, plainbytes.Length)
cs.Close()
cipherbytes = ms.ToArray()
ms.Close()
'display ciphertext as text string
m_cipertext = Encoding.UTF8.GetString(cipherbytes)


 
Run the output of your encryption through Convert.ToBase64String. This will produce a string that can be used without any concerns over the character set encoding, since the characters used in Base64 encoding are the same in both ASCII and Unicode.

When you go to decrypt it, run it through Convert.FromBase64String to change it back into a byte array, which you can then decrypt.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
excellent solution Chiph it was 100% spot on.
It was the last hurdle to this class and you solved it.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top