What is Hashing?
Hashing is the process of creating a key that represents a piece of data in a given context. In other words, “Hashing is using some function or algorithm to map object data to some representative integer value” (FreeCodeCamp.com). Hashing can be used in many different contexts, some of which we will explore in this blog.
How does a hashing function work?
According to Bart Preneel in his article Mash Hash Functions (Modular Arithmetic Secure Hash), “A hash function is a cryptographic algorithm that takes input strings of arbitrary (or very large) length, and maps these to short fixed length output strings.” Essentially, hashing functions are one way to turn identifiable data into an anonymous key, or to create an index for storing a value in a data structure. There are many ways to implement a hashing function. It is important that the hashing function returns the same index for the same input every time it runs, or else the stored data would not be consistently accessible. When creating an index to store data, the produced hash must stay within the storage limit of the data structure.
Where can we use hashing?
Example 1: Hash Tables
Example 2: User Passwords Security
When a user is visiting a website, they may need to sign in to access certain usability of the site. In that case each user will have a username and password to provide security. When a user inputs their password that information will be passed to a server to provide access. However, this process introduces security concerns if passwords and user info were moved as plaintext. Hashing is a way to move that information between the client and server with much less risk to the user.
What is the difference between encryption and hashing?
According to William Jackson’s article Why Salted Hash Is As Good For Passwords As For Breakfast, “Encryption is a two-way function” which can be unlocked with the correct key. “Hashing, is a one-way function” that produces a unique index or id which if done well, cannot be decoded. For Additional security, a salt, or a random string of characters, can be added to the key before hashing to introduce an additional element of randomness, therefore producing a stronger hash. Hashing with salt is a common security strategy and helps to protect against malicious hackers using rainbow tables.
In conclusion, hashing has many applications and is an important concept and tool in program development. Hashing can provide accurate and secure data storage, and protect user data from attacks.