magritton
7/2/2014 - 3:25 PM

This creates a has of a string in javascript. This was used to compare two lines of data in a better way.

This creates a has of a string in javascript. This was used to compare two lines of data in a better way.

function getHash(str)
{
	var hash = 0;
	if (str.length == 0) return hash;
	for (i = 0; i < str.length; i++) {
		char = str.charCodeAt(i);
		hash = ((hash<<5)-hash)+char;
		hash = hash & hash; // Convert to 32bit integer
	}
	return hash;
}