ALERT

[WEBINAR] Fast Analytics for Big Data and Small

Hash Code

Definition - What does Hash Code mean?

Hash code in .NET framework is a numeric value which helps in identification of an object during equality testing and also can serve as an index for the object. The value contained in the hash code is not permanent in nature. The purpose of hash code is to help in efficient lookup and insertion in data collections which are based on a hash table.

Techopedia explains Hash Code

Two objects are considered equal if they return equal hash codes. However, matching resultant hash codes do not necessarily mean object equality, or in other words, the reverse does not hold true. Because of this reason, hash code should never be used outside the boundaries of the application domain, as the same object could have different values outside the domain, processes or platforms.

As the value in hash code is temporary in nature, it should never be used as a key for data retrieval from a keyed data collection and should never be serialized or stored in databases. The GetHashCode method is used in .NET framework to get the hash code. It is suited for hashing algorithms or for data structures such as hash tables. The value returned by the function could differ between different .NET framework versions. As such, the framework does not approve the default implementation of the method, and so should not be used for finding the unique object identifier in the case of hashing purposes.

Hash code can aid in data comparison tasks. It can also help in one-way encryption, as the generated numeric value cannot be traced back to the original message data.

Share this: