ASCIIEncoding.GetString returns different values

  • Thread starter Thread starter jason.pileski
  • Start date Start date
J

jason.pileski

I'm converting an asp.net 1.1 app to 2.0 and am having difficulty
determining why ASCIIEncoding.GetString returns a different value in
..NET 2.0 than 1.1. The code is simple but I can't locate the problem.
If someone could point out my oversight, I'd greatly appreciate it.

Thanks in advance!

Dim md5Hasher As New MD5CryptoServiceProvider
Dim encoder As New ASCIIEncoding
Dim strHashedBytes As Byte() =
md5Hasher.ComputeHash(encoder.GetBytes(SOMESTRING))

Return encoder.GetString(strHashedBytes)
 
I'm converting an asp.net 1.1 app to 2.0 and am having difficulty
determining why ASCIIEncoding.GetString returns a different value in
.NET 2.0 than 1.1.

I think there were some changes in how it handles byte values > 127.
But those are outside the ASCII range and if you have that in your
data (which you most likely will have in a computed hash) you
shouldn't be using ASCIIEncoding at all.

For random binary data, you should consider using Base64 encoding
instead if you need to store a string representation of it.


Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top