I was in the need to have a hash function for strings. I copied some code from stackoverflow.com and it didn't work for strings "aa", "aaa", and so on, so I modified it a little bit. However, I don't know if it is stable - but it works for me.

Have fun:

Code:
long str_hash (STRING* str) {
	
	int c;
	long hash = 5381;
	
	char* cstr = _chr(str);
	
	int index;
	
	while (c = *cstr++, index++) {
		hash = (((hash << str_len(str)) + hash) + c + str_len(str)); 
	}

	return hash;
}