2.4.1 Unicode String to Unsigned Integer Hash

Given a null-terminated Unicode string, a 4-byte unsigned integer hash value can be obtained by performing the following algorithm:

  1. Set a 4-byte unsigned integer value dwHash equal to 0x00000000.

  2. Truncate the input string to 255 characters plus the null-terminating character.

  3. Convert the input string to lower case.

  4. For each set of 2 characters (Char1, Char2) from position 0 to the end of the input string (for example, [0,1], [2,3], [4,5], …, [255, <null>]) perform the following steps.

    Example:

     for (i=0; i<wcslen(inputString); i+=2)
         Char1 = inputString[i];
         Char2 = inputString[i+1];
    
    1. Set an unsigned 4-byte integer value, dwNext, equal to the bitwise OR of Char2 shifted 16 bits to the high order and Char1.

      Example: dwNext = (Char2 << 16) | Char1;

    2. Set dwHash equal to the exclusive OR between dwHash and dwNext.

      Example: dwHash = dwHash ^ dwNext;

  5. The result of the algorithm is the value dwHash.