Javascript-js tutorial

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.