P
Peter Morris [Droopy Eyes Software]
Hi all
I am creating a kind of authorisation process in my CF application and part
of this requires the use of string.GetHashCode.
Unfortunately I have discovered that the result of this method in CF returns
a different value to that of the one from the full framework.
Can anyone suggest a way to get my Desktop app to produce the same value? I
have tried disassembling the CF version using Reflector but I cannot get it
to compile...
public override unsafe int GetHashCode()
{
if (AppDomain.CompatVersion.Major == 1)
{
goto Label_0057;
}
fixed (char* chRef1 = &this.m_firstChar)
{
int num1;
int num4;
char* chPtr1 = chRef1;
int num2 = 0x1505;
int num3 = num2;
while ((num1 = chPtr1[0]) != '\0')
{
num2 = ((num2 << 5) + num2) ^ num1;
num1 = chPtr1[1];
if (num1 == 0)
{
break;
}
num3 = ((num3 << 5) + num3) ^ num1;
chPtr1 += 2;
}
return (num2 + (num3 * 0x5d588b65));
Label_0057:
num4 = 0x1505;
int num5 = this.Length;
fixed (char* chRef2 = &this.m_firstChar)
{
for (int num6 = 0; num6 < num5; num6++)
{
num4 = ((num4 << 5) + num4) ^ chRef2[num6];
}
}
return num4;
}
}
Thanks
Pete
I am creating a kind of authorisation process in my CF application and part
of this requires the use of string.GetHashCode.
Unfortunately I have discovered that the result of this method in CF returns
a different value to that of the one from the full framework.
Can anyone suggest a way to get my Desktop app to produce the same value? I
have tried disassembling the CF version using Reflector but I cannot get it
to compile...
public override unsafe int GetHashCode()
{
if (AppDomain.CompatVersion.Major == 1)
{
goto Label_0057;
}
fixed (char* chRef1 = &this.m_firstChar)
{
int num1;
int num4;
char* chPtr1 = chRef1;
int num2 = 0x1505;
int num3 = num2;
while ((num1 = chPtr1[0]) != '\0')
{
num2 = ((num2 << 5) + num2) ^ num1;
num1 = chPtr1[1];
if (num1 == 0)
{
break;
}
num3 = ((num3 << 5) + num3) ^ num1;
chPtr1 += 2;
}
return (num2 + (num3 * 0x5d588b65));
Label_0057:
num4 = 0x1505;
int num5 = this.Length;
fixed (char* chRef2 = &this.m_firstChar)
{
for (int num6 = 0; num6 < num5; num6++)
{
num4 = ((num4 << 5) + num4) ^ chRef2[num6];
}
}
return num4;
}
}
Thanks
Pete