Many a times you hear this term call hash function or hashcode. One of the most common usage is in Java when discussing about Hashset or HashMap. Lets understand what is Hashcode and HashFunction.
What is Hash Function?
A hash function is any function that can be used to map data of arbitrary size to data of fixed size -wikipediea
In simple terms, think of hash function as a juicer where you can put any fruit and the result is always a juice. As the juicer is one way that is once you make the juice out of a fruit you cannot reverse the propose i.e. you cannot get the fruit back out of the juice. The same thing goes with the hash function once you get the resultant value you cannot reverse it. This is very important in information security and some people use this to store passwords ( they are other better ways to store passwords like salt technique but we wont discuss this in this post).
What is HashCode
Hash code is the resultant of the hash function (its the final juice that comes out of the juicer). The length of hashcode is fixed (same like the juicer you always wanted a cup full of juice). Hashcode is used to validate of two results are same or different.
In Java, hashcode is used in hashset and hashmap.
Comments
Post a Comment