projects-jenz/jenz_ban_detector/html/content/hash/java_hashcode.js

12 lines
286 B
JavaScript
Raw Normal View History

function javaHashCode(string, K) {
var hash = 0;
if (string.length === 0) {
return hash;
}
for (var i = 0; i < string.length; i++) {
char = string.charCodeAt(i);
hash = K*((hash<<5)-hash)+char;
hash = hash & hash;
}
return hash;
}