ASCIIEncoding.GetString returns different values

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jason.pileski@pacourts.us

    #1

    ASCIIEncoding.GetString returns different values

    I'm converting an asp.net 1.1 app to 2.0 and am having difficulty
    determining why ASCIIEncoding.G etString 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 MD5CryptoServic eProvider
    Dim encoder As New ASCIIEncoding
    Dim strHashedBytes As Byte() =
    md5Hasher.Compu teHash(encoder. GetBytes(SOMEST RING))

    Return encoder.GetStri ng(strHashedByt es)

  • Mattias Sjögren

    #2
    Re: ASCIIEncoding.G etString returns different values

    >I'm converting an asp.net 1.1 app to 2.0 and am having difficulty
    >determining why ASCIIEncoding.G etString 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

    --
    Mattias Sjögren [C# MVP] mattias @ mvps.org
    http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
    Please reply only to the newsgroup.

    Comment

    Working...