T
Tomppa
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.ToString("X2"));
}
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
return sb.ToString();
}
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.ToString("X2"));
}
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
return sb.ToString();
}