JS Hash

JS is a bitwise hash function algorithm.



									/*****Please include following header files*****/
// string
/***********************************************/

/*****Please use following namespaces*****/
// std
/*****************************************/

static unsigned int JSHash(string str) {
	unsigned int hash = 1315423911;
	unsigned int i = 0;
	unsigned int len = str.length();

	for (i = 0; i < len; i++)
	{
		hash ^= ((hash << 5) + (str[i]) + (hash >> 2));
	}

	return hash;
}
								


Example

									string data = "jdfgsdhfsdfsd 6445dsfsd7fg/*/+bfjsdgf%$^";
unsigned int value = JSHash(data);
								


Output

									3189953700