Hashed strings - Gametoast/Documentation GitHub Wiki

This is an 'advanced' topic.

Star Wars Battlefront (2004) and Star Wars Battlefront II (2005) will use a 'compression technique' with many of 'strings' used in game files. In many cases (configuration/ODF properties, string keys, file names) the game will use a hash algorithm to compress a string down to 4 bytes. When using the unmunge program you will often see strange numbers in place of file names, string keys, config file properties... This is because in order to properly 'un-do' a hash value, you must first know what it was to begin with. Starting on version 1.2.1 of the unmunge program you are given the opportunity to give it an added dictionary of strings that it can use to lookup more hashed strings.

Guessing a hash value

In some cases you may want to figure out or 'guess' a hash value of something you find interesting. The modtools ships with a program called 'Hash.exe' that we can use to guess or verify a guess of a hashed string.

Examining the help message of the program we can see:

C:\BF2_ModTools\ToolsFL\bin>Hash.exe
Usage:
Hash [-i] [-//|-x] [-l=<length>] [-c=<charlist>] <string|hashid>
The -i switch performs an inverse hash of the primary argument,
    interpretting it as a hexadecimal hashid.
The -// switch sets the output format to use a // comment.
The -x switch sets the output format to just a hash/string
The -c switch sets the character set to use for inverse hash
    lookups as a sequence of ranges.  i.e. -c=a-z0-9_ will use
    letters, numbers, and underscores only.  The default range is
    all non-control ANSI characters.  A space character can only
    be added to the range by making it the first character after
    the equal sign, i.e. -c= -_
For example : Hash test
              will produce the output "0xafd071e5 /* "test" */"
              Hash -i 0xafd071e5 -l=4 -c=a-z
              will produce the output "test"
The hash value is generated using the FNV-1a algorithm.
Case sensitivity is suppressed by binary 'or' with 0x20.
The FNV algorithm is in the public domain.
See http://www.isthe.com/chongo/tech/comp/fnv/

Using the hash.exe program

To check the hash value of a string we can do:

C:\BF2_ModTools\ToolsFL\bin>hash.exe CyclePlayback
0x4d5af670 /* "CyclePlayback" */

To attempt a reverse hash lookup operation (using only characters 'a' through 'z' ,'.' and '_') we can do:

C:\BF2_ModTools\ToolsFL\bin>hash.exe -i 0x4d5af670 -c=a-z._

You'll notice that this takes a long time and therefore it is not a terribly practical solution for reverse hash lookup. This technique was used to successfully lookup the PSP-only ODF property of 'IsJedi' (was successful because of it's short length).

more details If you cannot find the string you are looking for, the inverse lookup feature will present you with several other values that you could use in it's place and still have things 'work' correctly.

For example, in the case of the 'CyclePlayback' property mentioned in the example above; we could have used in its place one of the results of the inverse lookup:

Z:\BF2_ModTools\ToolsFL\bin>hash.exe -i 0x4d5af670 -c=a-z
        Length:1:
        Length:2:
        Length:3:
        Length:4:
        Length:5:
        Length:6:
        Length:7:
        Length:8:
0x4d5af670 /* "atkucyoq" */
0x4d5af670 /* "bdfvyxtz" */
0x4d5af670 /* "blxbkgyf" */
0x4d5af670 /* "ctjwtsxp" */
0x4d5af670 /* "ctpxayzf" */
0x4d5af670 /* "dmzflszs" */
0x4d5af670 /* "dtytbqlk" */
0x4d5af670 /* "duumphkq" */
0x4d5af670 /* "dvpvhmue" */
0x4d5af670 /* "ebfztjxl" */
0x4d5af670 /* "eofdkfrd" */
0x4d5af670 /* "fsyeddxp" */
0x4d5af670 /* "gdaidwmx" */
0x4d5af670 /* "glejtviv" */
...
⚠️ **GitHub.com Fallback** ⚠️