FNV

From SimsWiki
Revision as of 07:26, 17 June 2009 by Dd764ta (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

FNV hash function

Overview

The [Fowler-Noll-Vo hash function] is used in various Sims 3 resources, be it the 32 or 64 bit form, it is used in the generation of property ids, instance ids, bone ids, etc.

Formula

The hash is generated with an initial offset, which is multiplied by a prime number and XOR'ed by each byte of data.

FNV(byte[] data)
{
	hash = offset;
	foreach(byte b in data)
	{
		hash *= prime;
		hash ^= b;
	}
	return hash;
}

Constants

Bits Prime Offset
32 0x01000193 0x811C9DC5
64 0x00000100000001B3 0xCBF29CE484222325
Personal tools
Namespaces

Variants
Actions
Navigation
game select
Toolbox