Hash Code

Why Trust Techopedia

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.

Advertisements

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.

Advertisements

Related Terms

Margaret Rouse
Technology Specialist
Margaret Rouse
Technology Specialist

Margaret is an award-winning writer and educator known for her ability to explain complex technical topics to a non-technical business audience. Over the past twenty years, her IT definitions have been published by Que in an encyclopedia of technology terms and cited in articles in the New York Times, Time Magazine, USA Today, ZDNet, PC Magazine, and Discovery Magazine. She joined Techopedia in 2011. Margaret’s idea of ​​a fun day is to help IT and business professionals to learn to speak each other’s highly specialized languages.