Hash can be considered as an associated array. It binds a unique key to each value (the value must not be unique). However, it cannot ensure that the element sequence is consistent during iteration. Because of the features of JavaScript programming language, every object is actually a hash. Next we will discuss it in detail. The function that computes string or file hash values with high performance is much faster than md5, and it is always used by itself. The probability of repetition is very low, and the general application is sufficient,
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 ;}
The above is all the content of this article. I hope you will like it.