Re: HMACSHA1 Hash Different from desktop to WinCE



My bad,

This does work.

My salt value was null on one end and an expty string on the other.

"Tomppa" <t.o.m.p.p.a.@xxxxxxxxx> wrote in message
news:%23Qauwlc3GHA.2196@xxxxxxxxxxxxxxxxxxxxxxx
How can I create a hash of a string on the desktop using a salt value and
get the same results on my WinCE device?

I use the same code on the desktop and pc with the same hash of the same
string with different results.

I the string I am hashing is a guid string.

Desktop framework 2.0 CF framework 2.0 WinCE 5

Thanks in advance...


public static string GetHashFromString(string stringValue)

{

StringBuilder sb = new StringBuilder();

try

{

System.Text.ASCIIEncoding encoding=new System.Text.ASCIIEncoding();

byte[] fileBytes = encoding.GetBytes(stringValue);

// generate hash

HMACSHA1 hmac = new HMACSHA1();


string key = RegistryHelper.HashKey;

if (key.Length > 0)

{

hmac.Key = Encoding.ASCII.GetBytes(key);

}

else

{

hmac.Key = Encoding.ASCII.GetBytes("");

}

hmac.ComputeHash(fileBytes);

// convert hash to hex string

for (int i = 0; i < hmac.Hash.Length; i++)

{

sb.Append(hmac.Hash[i].ToString("X2"));

}

}

catch (Exception ex)

{

Debug.WriteLine(ex.Message);

}

return sb.ToString();

}




.



Relevant Pages

  • Re: silly Q: How do I use the string table?
    ... You can get a direct pointer to the resource so you don't need to make a copy. ... Or write your own string lookup - it's easy enough to do - that will return a direct pointer (look in WinCE shared source code). ... Use that for both WinCE and desktop builds instead of LoadString. ... It seems like LoadString would require more overhead because now I have to create a buffer to receive the string before it can be used. ...
    (microsoft.public.pocketpc.developer)
  • Re: Load string into Edit box
    ... Just a warning that that code works (make sure you do have /n on resource ... You have to load the string into a buffer. ... you'll never port than you're golden at least on WinCE 5.0 and lower. ... what resource compiler you are using. ...
    (microsoft.public.windowsce.embedded.vc)
  • Re: Can MultiByteToWideChar translate from utf-8 to unicode?
    ... you can pass CP_UTF8 for the codepage ... It's not documented to work for WinCE, though, but give it a ... > My program read a utf-8 format string from a file. ...
    (microsoft.public.pocketpc.developer)
  • RE: passing string array to C++
    ... all the System API on the WinCE is of Unicode ... string all the time. ... CPPDLL_API long MyAdapt(long g, WCHAR **strings, long numStrings) ...
    (microsoft.public.dotnet.framework.interop)
  • HMACSHA1 Hash Different from desktop to WinCE
    ... get the same results on my WinCE device? ... I use the same code on the desktop and pc with the same hash of the same ... string with different results. ... Desktop framework 2.0 CF framework 2.0 WinCE 5 ...
    (microsoft.public.dotnet.framework.compactframework)