Spiegato, Home

Technology and Gadgets

What are Hashes?

  • Published by Spiegato
  • 2 min read

Hashes are mathematical formulas that take a string of data of variable length, usually in the form of text, and convert it into shorter, fixed-length numeric values. Hashes are used frequently in computer databases in order to make searches faster and more efficient. They are also used in encryption to ensure that passwords are not compromised and to authenticate digital signatures, among other uses. Hashes also go by the name of hash functions, and can also be considered algorithms.

Hashes play a big role in facilitating database searches. In a database consisting of names, for example, if a user searches for “John Doe,” the computer would have to match up all of the characters in the search to those of every database entry. Every character in the name would have 26 different possibilities — the letters of the English alphabet — while the variable length of the entries would also slow down the search.

By contrast, applying a hash function would make the computer’s life much easier. Turning each text string into a series of numbers would simplify the search, because the computer would only have ten possibilities to check for each character: digits “0” to “9.” The fixed length of the number series also helps the computer do its job more efficiently.

In a database with a hash function applied, all entries have a corresponding, unique number. This is called a hash key. In this instance, when you make a search, the computer first applies the hash function to the input you’ve written, such as “John Doe.” This results in a numeric value, for example “456789.” The computer can then rapidly match this result to the hash key corresponding to the correct entry.

Hashes also function as digital signatures. For example, a sender, Robert, wants to send a document to someone and the recipient, Mary, wants to make sure the document hasn’t been tampered with while en route. The sender, Robert, only has to run the document through a hash function, which results in a numeric value. Robert then encrypts the hash key and sends the document along with the encrypted key.

Mary receives both items and decrypts the hash key. She can now see the numerical value that resulted from the document before it was sent. To verify that the document in her hands is the exact same one, she runs the document through a hash function on her computer. Lastly, she compares both keys. If they are the same, then the document wasn’t altered on its way to the recipient.

Many different hash functions exist, each with their own mathematical formulas. For a hash function to work, it must minimize any collision, which occurs when two database entries have the same hash key. Hash functions must also be one-way. That means you can produce a key from a database entry or document, but not the other way around. In other words, you cannot “reverse-engineer” the original document from its hash key.

Key terms in this article

Related articles

  • What is a Hashtag?

    Twitter® is a social networking website on which people create profiles, “follow” or “unfollow” others, and communicate in posts of 140 characters or…

  • What is a Hashing Algorithm?

    Computer programmers have been using hashing functions for decades. These functions are typically used in the areas of security, data access, or data…

  • What are Hash Files?

    Computer security is an important aspect for most businesses. Many organizations use a process of hashing data into hash files to encrypt important data…

  • What is a Hash Converter?

    Cryptology has been used for centuries as a method of creating secret messages. This science is based on enciphering and deciphering messages using secret…

  • What is a Hashtable Key?

    Computer programming is the process that automates computer software. Most computer programs store digital data in files. A hash table is a special table…