BKDR Hash

BKDR is a simple hash function using a strange set of possible seeds which all constitute a pattern of 31....31...31 etc.



									public static uint BKDRHash(string str)
{
	uint seed = 131;
	uint hash = 0;
	uint i = 0;

	for (i = 0; i < str.Length; i++)
	{
		hash = (hash * seed) + ((byte)str[(int)i]);
	}

	return hash;
}
								


Example

									string data = "jdfgsdhfsdfsd 6445dsfsd7fg/*/+bfjsdgf%$^";
uint value = BKDRHash(data);
								


Output

									3255416723