The javascript implementation gets the string hash value
- 2020-06-07 04:02:30
- OfStack
High performance functions that calculate the value of a string or file, hash, are much faster than md5, are used directly by themselves, have a very low repetition rate, and have enough applications of 1.
var I64BIT_TABLE =
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-'.split('');
function hash(input){
var hash = 5381;
var i = input.length - 1;
if(typeof input == 'string'){
for (; i > -1; i--)
hash += (hash << 5) + input.charCodeAt(i);
}
else{
for (; i > -1; i--)
hash += (hash << 5) + input[i];
}
var value = hash & 0x7FFFFFFF;
var retValue = '';
do{
retValue += I64BIT_TABLE[value & 0x3F];
}
while(value >>= 6);
return retValue;
}
This is the end of this article, I hope you enjoy it.