Differences and relationships between the hashcode () and Equals () methods

Source: Internet
Author: User

1. What is a hashing algorithm.

First look at a few concepts, the following excerpt from Wikipedia

hash function:

/*
 hash function (or hash algorithm, also known as hash function, English: hash functions) is a way to create a small number "fingerprint" from any kind of data. The
hash function compresses the message or data into a digest, which makes the data quantity smaller and the data format fixed. The function disrupts the data and recreate a
fingerprint called the hash value (hash Values,hash Codes,hash sums, or hashes). A hash value is usually used to represent a short random letter and a string of numbers. A
good hash function rarely has a hash conflict in an input field. In hashing and data processing, not suppressing conflicts to differentiate data makes database records more difficult to find.
 */


The nature of the hash function:

/*
 All hash functions have the following basic characteristics: If the two hash values are different (according to the same function), then the original input of the two hash values is also different.
This property is a deterministic result of the hash function, and a hash function with this property is called a one-way hash function. On the other hand, the input and output of the hash function are not
the only corresponding relationships, if two hash values are the same, two input values are likely to be the same, but may also be different, which is called a "hash collision," which is usually two different lengths
of input values, calculated to calculate the same output value. Enter some data to calculate the hash value, and then partially change the input value, and a hash function with a strong obfuscation attribute produces
a completely different hash value.
 */


Based on the above concept, you can summarize:

As input, do hashing algorithm, the result must be the same;

On the contrary, not tenable.


2. Not finished.


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.