Why Trust Techopedia

What Does Hashing Mean?

Hashing is the process of translating a given key into a code. A hash function is used to substitute the information with a newly generated hash code. More specifically, hashing is the practice of taking a string or input key, a variable created for storing narrative data, and representing it with a hash value, which is typically determined by an algorithm and constitutes a much shorter string than the original.


The hash table will create a list where all value pairs are stored and easily accessed through its index. The result is a technique for accessing key values in a database table in a very efficient manner as well as a method to improve the security of a database through encryption.

Hashing makes use of algorithms that transform blocks of data from a file in a much shorter value or key of a fixed length that represent those strings. The resulting hash value is a sort of concentrated summary of every string within a given file, and should be able to change even when a single byte of data in that file is changed (avalanche effect). This provides massive benefits in hashing in terms of data compression. While hashing is not compression, it can operate very much like file compression in that it takes a larger data set and shrinks it into a more manageable form.

Suppose you had “John’s wallet ID” written 4000 times throughout a database. By taking all of those repetitive strings and hashing them into a shorter string, you’re saving tons of memory space.

Techopedia Explains Hashing

Think of a three-word phrase encoded in a database or other memory location that can be hashed into a short alphanumeric value composed of only a few letters and numbers. This can be incredibly efficient at scale, and that’s just one reason that hashing is being used.

Hashing in Computer Science and Encryption

Hashing has several key uses in computer science. One that perhaps receives the most attention today in a world where cybersecurity is key is the use of hashing in encryption.

Because hashed strings and inputs are not in their original form, they can’t be stolen the way they could be if they are not hashed. If a hacker reaches into a database and finds an original string like “John’s wallet ID 34567,” they can simply glean, nab or pilfer this information and use it to their advantage, but if they instead find a hash value like “a67b2,” that information is completely useless to them, unless they have a key to decipher it. SHA-1, SHA-2, and MD5, are popular cryptographic hashes.

A good hash function for security purposes must be a unidirectional process that uses a one-way hashing algorithm. Otherwise, hackers could easily reverse engineer the hash to convert it back to the original data, defeating the purpose of the encryption in the first place.

To further increase the uniqueness of encrypted outputs, random data could be added to the input of a hash function. This technique is known as “salting” and guarantees unique output even in the case of identical inputs. For example, hackers can guess users’ passwords in a database using a rainbow table or access them using a dictionary attack. Some users may share the same password that, if guessed by the hacker, is stolen for all of them. Adding the salt prevents the hacker from accessing these non-unique passwords as each hash value will now be unique, and will stop any rainbow table attack.

Using Hashing in Database Retrieval

Hashing can be used in database retrieval. Here’s where another example comes in handy — many experts analogize hashing to a key library innovation of the 20th century — the Dewey decimal system.

In a sense, what you get when you retrieve a hash value is like getting a Dewey decimal system number for a book. Instead of searching for the book’s title, you’re searching for the Dewey decimal system address or identification, plus a few key alphanumeric characters of the book’s title or author.

We’ve seen how well the Dewey decimal system has worked in libraries, and it works just as well in computer science. In short, by shrinking these original input strings and data assets into short alphanumeric hash keys, engineers are able to do several key cybersecurity enhancements and save file space at the same time.

Hashing’s Role in File Tampering

Hashing is also valuable in preventing or analyzing file tampering. The original file will generate a hash which is kept with the file data. The file and the hash are sent together, and the receiving party checks that hash to see if the file has been compromised. If there were any changes to the file, the hash will show that.

All of this shows why hashing is such a popular part of DB handling.


Related Terms

Margaret Rouse
Technology Expert
Margaret Rouse
Technology Expert

Margaret is an award-winning technical writer and teacher known for her ability to explain complex technical subjects 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 by 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 helping IT and business professionals learn to speak each other’s highly specialized languages.