mrhands

Sexy game(s) maker

  • he/him

I do UI programming for AAA games and I have opinions about adult games


Discord
mrhands31

I'm doing some more C++ experimentation, and I'm pleased to present to you a hashing function that is:

  • Windows-only 1
  • Case insensitive, so "Hello World!" and "HeLlo WoRld!" both result in the same hash value
  • 16-bit precision because even though the Windows function returns a 32-bit integer, the upper 4 bytes are always 0x0010

But hey, no external dependencies! All you have to do to use this function is include oleauto.h and link against OleAut32.lib 😄2

#include <oleauto.h>
​
uint16_t HashCaseInsensitive(std::string_view name)
{
	return ::LHashValOfNameSysA(SYS_WIN64, LOCALE_SYSTEM_DEFAULT, name.data()) & 0xFFFF;
}

  1. There's a SYS_MAC as well for some curséd reason.

  2. You probably don't want to use this in production.


You must log in to comment.