Rotr32 Add 13

#include <Windows.h>

UINT32 ImplRotateRight32(UINT32 x, UINT32 Rotate)
{
    return (x >> Rotate) | (x << (32 - Rotate));
}

UINT32 HashStringRotateRight13Inc(PWCHAR String)
{
    UINT32 Hash = 0;

    for (; *String; String++)
    {
        WCHAR Index = *String;

        if (Index >= 'a' && Index <= 'z')
            Index -= 32;

        Hash = ImplRotateRight32(Hash, 13);
        Hash += (UINT8)Index;
    }

    return Hash;
}

INT main(VOID)
{
	WCHAR StringHashExample[] = L"Hash This String";
	UINT32 Hash = 0;

  Hash = HashStringRotateRight13Inc(StringHashExample);

	return ERROR_SUCCESS;
}

Last updated