Create HashStringJenkinsOneAtATime32Bit.cpp

This commit is contained in:
vxunderground 2022-07-14 22:29:49 -05:00 committed by GitHub
parent ff055b5b50
commit cc9b0fdf2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,39 @@
UINT32 HashStringJenkinsOneAtATime32BitA(PCHAR String)
{
SIZE_T Index = 0;
UINT32 Hash = 0;
SIZE_T Length = StringLengthA(String);
while (Index != Length)
{
Hash += String[Index++];
Hash += Hash << 10;
Hash ^= Hash >> 6;
}
Hash += Hash << 3;
Hash ^= Hash >> 11;
Hash += Hash << 15;
return Hash;
}
UINT32 HashStringJenkinsOneAtATime32BitW(PWCHAR String)
{
SIZE_T Index = 0;
UINT32 Hash = 0;
SIZE_T Length = StringLengthW(String);
while (Index != Length)
{
Hash += String[Index++];
Hash += Hash << 10;
Hash ^= Hash >> 6;
}
Hash += Hash << 3;
Hash ^= Hash >> 11;
Hash += Hash << 15;
return Hash;
}