AP Hash

AP is a hybrid rotative and additive hash function algorithm.



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

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

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

	for (i = 0; i < len; i++)
	{
		hash ^= ((i & 1) == 0) ? ((hash << 7) ^ (str[i]) * (hash >> 3)) :
			(~((hash << 11) + ((str[i]) ^ (hash >> 5))));
	}

	return hash;
}
								


Example

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


Output

									2799550922