Re: ??Difference Between utf8encoder.GetBytes and Encoding.ASCII.GetBytes
From: Phil C. (charlestek_at_rcn.com)
Date: 02/24/05
- Next message: pwstevens_at_hotmail.com: "Re: Roles and Permissions??"
- Previous message: Joe Kaplan \(MVP - ADSI\): "Re: ??Difference Between utf8encoder.GetBytes and Encoding.ASCII.GetBytes"
- In reply to: Joe Kaplan \(MVP - ADSI\): "Re: ??Difference Between utf8encoder.GetBytes and Encoding.ASCII.GetBytes"
- Next in thread: Joe Kaplan \(MVP - ADSI\): "Re: ??Difference Between utf8encoder.GetBytes and Encoding.ASCII.GetBytes"
- Reply: Joe Kaplan \(MVP - ADSI\): "Re: ??Difference Between utf8encoder.GetBytes and Encoding.ASCII.GetBytes"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Thu, 24 Feb 2005 15:35:15 -0500
Thank you Joe, you saved me a lot of grief.
However, then, what is the difference between UTF8Encoding.GetBytes("text")
and Encoding.Unicode.GetBytes("text)
or the converse
UTF8Encoding.GetString(Byte())
Encoding.Unicode.GetString(Byte())
??
-----------------------------------------------------------------------------------------------------------------------------------------------------
"Joe Kaplan (MVP - ADSI)" <joseph.e.kaplan@removethis.accenture.com> wrote
in message news:uyWgMXqGFHA.2616@tk2msftngp13.phx.gbl...
> Generally speaking, the different encoding classes will give you an array
> of bytes from a string corresponding to how that encoding actually
> represents a string. Unicode (UTF16) represents each character as 2
> bytes. UTF8 will use a variable number of bytes for each character, but
> uses only one for ASCII characters, so it generally uses much less space
> to store the same Unicode data.
>
> ASCII converts characters into a single byte using only 7 bits of each
> byte. Since it only supports ASCII characters, it can result in data loss
> if the string in question contains non-ASCII characters. It rarely has a
> use in .NET crypto since strings are unicode in .NET.
>
> If your encryption key is stored as text, it is probably stored in Base64.
> In that case, you probably want to use Convert.FromBase64String to convert
> the string key into a byte array.
>
> Joe K.
>
> "Phil C." <charlestek@rcn.com> wrote in message
> news:u6LpKgpGFHA.2616@tk2msftngp13.phx.gbl...
>> Hi. (Using VB.Net) I have a symmetric encryption key stored as text,
>> encrytped by DPAPI in my web config that I use a handler
>> class to decrypt by the DPAPI and pass to the class that does the
>> encryption/decryption.
>> The decrypted DPAPI key is a string and needs to be converted to a byte
>> array for use by the encryption/decryption class. I'm confused as to the
>> difference using utf8encoder.GetBytes() or Encoding.ASCII.GetBytes() to
>> do this.
>>
>> Thanks,
>>
>> Phil
>> Boston, MA
>>
>
>
- Next message: pwstevens_at_hotmail.com: "Re: Roles and Permissions??"
- Previous message: Joe Kaplan \(MVP - ADSI\): "Re: ??Difference Between utf8encoder.GetBytes and Encoding.ASCII.GetBytes"
- In reply to: Joe Kaplan \(MVP - ADSI\): "Re: ??Difference Between utf8encoder.GetBytes and Encoding.ASCII.GetBytes"
- Next in thread: Joe Kaplan \(MVP - ADSI\): "Re: ??Difference Between utf8encoder.GetBytes and Encoding.ASCII.GetBytes"
- Reply: Joe Kaplan \(MVP - ADSI\): "Re: ??Difference Between utf8encoder.GetBytes and Encoding.ASCII.GetBytes"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|