我必须使 java 函数与 jQuery 兼容。jQuery Real Person captcha validate 函数是由 java 编写的。我想在 jQuery 中验证验证码。所以,我尝试用 jQuery 编写 java 函数。但是该函数无法返回正确的值。
爪哇:
private String rpHash(String value) {
int hash = 5381;
value = value.toUpperCase();
for(int i = 0; i < value.length(); i++) {
hash = ((hash << 5) + hash) + value.charAt(i);
}
return String.valueOf(hash);
}
jQuery:
function rpHash(value) {
hash = 5381;
value = value.toUpperCase();
for($i = 0; $i < value.length; $i++) {
hash = ((hash << 5) + hash) + value.charAt($i);
}
return hash;
}