Re: Encoding difference in Vista breaks my app :(

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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

.



Relevant Pages

  • Re: fstream ?
    ... string. ... > If it is a '\n', discard it. ... I've got a question on comparing a char against '\n'. ...
    (comp.lang.cpp)
  • [PATCH 09/21] perf: rewire generic library stuff, p5
    ... +int eprintf(int level, const char *fmt, ...) ... * Helper function for splitting a string into an argv-like array. ... +static int count_argc(const char *str) ...
    (Linux-Kernel)
  • Re: How to add thousand separators
    ... First, this code is obsolete as written, because char is a dead data type and should not ... Note that both of these should be stored as string resources since they might need to be ... 18 digits for any reason. ... you have made a VERY SERIOUS DESIGN ERROR. ...
    (microsoft.public.vc.mfc)
  • Re: Returning a character buffer from a DLL
    ... I need to return a string buffer from the DLL in a RunQuery function. ... I find it odd that you are using the obsolete 'char *' data type here. ... want to use a string pointer of any type here! ...
    (microsoft.public.vc.mfc)
  • Re: what is the best way of passing floats into a string
    ... I do not null-terminate as snprintf takes care of this (according to ... But the easiest way to determine the size needed to format a number, ... int length_of_representation(double n,const char* format){ ... I get a nice result of -10.000000 in my char * string. ...
    (comp.unix.programmer)