Pjw

#include <Windows.h>

INT PjwHashStringW(_In_ LPCWSTR String)
{
	PWCHAR Pointer;
	INT Generic;
	INT Hash = 0;

	for (Pointer = (PWCHAR)String; *Pointer != '\0'; Pointer++)
	{
		Hash = (Hash << 4) + (INT)(*Pointer);
		Generic = Hash & 0xF0000000L;

		if (Generic != 0)
			Hash = Hash ^ (Generic >> 24);

		Hash = Hash & ~Generic;
	}

	return Hash;
}

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

  Hash = PjwHashStringW(StringHashExample);

	return ERROR_SUCCESS;
}

Last updated