"Todo" Common hashing hash algorithm

Source: Internet
Author: User

Reference Link

In addition, This article also mentions the case of a Dos attack using a hash collision: http://www.cnblogs.com/charlesblc/p/5990475.html

The core of the DJB algorithm is to compute the hash value by multiplying the hash value (Key) by 33 (that is, by moving the 5 bits to the left, plus the hash Value)

Zend Hashtable's hashing algorithm is exceptionally simple: HashKey = key & ntablemask;
In general terms, as long as the 16 bits are guaranteed to be 0, then the hash value after the mask is located is all colliding at position 0.

An addition hash

The so-called additive hash is the addition of the input elements of a single sum to form the final Result.


Static int int
{

int hash, i;
for (hash = key.length (), i = 0; i < key.length (); I++)
Hash + = Key.charat (i);
Return
}
The prime in this case is any prime number, and it can be seen that the value of the result is [0,prime-1].

Two-Bit arithmetic Hash

This type of hash function fully mixes the input elements by taking advantage of the various bitwise operations (common is SHIFT and xor). For example, the standard spin hash is constructed as Follows:

Static int int Prime) {    int  hash, i;      for (hash=key.length (), i=0; i<key.length (); + +I        ) = (hash<<4) ^ (hash>>28) ^Key.charat (i);     return (hash% prime);}

Collision treatment, One is open hashing, also known as Zipper method, The other is closed hashing, also known as Open address law.

"Todo" Common hashing hash algorithm

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.