Re: Encoding difference in Vista breaks my app :(
- From: "Tim_Mac" <tim.mackey@xxxxxxxxxxxxxxxx>
- Date: Fri, 6 Oct 2006 15:57:04 +0100
i've done some more testing and found that it wasn't safe to discard anything above ASCII 179.
a working version is to open up the hashed string into a Char array, and then check if the integer value of each one is 65533. If it is, the character should be discarded because it would not exist if you run the same code on Server 2003 or XP.
/// <summary>
/// This function hashes the text to MD5, in binary format
/// </summary>
public static string EncryptMd5Binary(string text)
{
UTF8Encoding encoder = new UTF8Encoding();
MD5CryptoServiceProvider md5Hasher = new MD5CryptoServiceProvider();
byte[] hashedBytes = md5Hasher.ComputeHash(encoder.GetBytes(text));
string hashedString = encoder.GetString(hashedBytes);
string result = "";
// strip out any chars that int to 65533, this only happens when running on vista
foreach (char c in hashedString.ToCharArray())
if ((int)c != 65533)
result += c;
return result;
}
can anyone explain what the difference is?
thanks
tim
.
- Follow-Ups:
- Re: Encoding difference in Vista breaks my app :(
- From: Jon Skeet [C# MVP]
- Re: Encoding difference in Vista breaks my app :(
- References:
- Encoding difference in Vista breaks my app :(
- From: Tim_Mac
- Encoding difference in Vista breaks my app :(
- Prev by Date: Encoding difference in Vista breaks my app :(
- Next by Date: Re: Encoding difference in Vista breaks my app :(
- Previous by thread: Encoding difference in Vista breaks my app :(
- Next by thread: Re: Encoding difference in Vista breaks my app :(
- Index(es):
Relevant Pages
|