> For the complete documentation index, see [llms.txt](https://malwaresourcecode.com/home/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://malwaresourcecode.com/home/string-hashing/pjw.md).

# Pjw

```cpp
#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;
}
```
