您的 IP 地址: 未知 · 您当前的状态: 受保护未受保护的未知
博客 In Depth

Hashing vs. encryption: what’s the difference?

While encryption is one of the best and most popular online protection tools, it's not the only way to shield your data. Take hashing, for example. While it’s similar to encryption, there are differences in how it works and where it can be used. But what is hashing? And how does it work?

Malcolm Higgins

Malcolm Higgins

Nov 22, 2021 · 4 min read

Hashing vs. encryption: what’s the difference?

What is hashing?

Hashing is a process that transforms your data into a random fixed-length value, using a hash function. For example, a piece of plain text (a password, for example) can be turned into a hashed value, making it very hard to decipher.

Hashing is a one-way process, which can't be directly reversed (as opposed to encryption, which can be decrypted if you have the appropriate decryption key). When companies store user data (usernames and passwords, let’s say), they can use hashing to ensure that the information stays private, even if they suffer a data breach.

Moreover, hashing ensures the integrity of data. When you send a hashed file to a friend, you provide a hashed value along with the message. A friend then calculates the hash value —if the values match, then the file hasn’t been tampered with while in transit.

Hashing is usually used to deal with large amounts of data. It is easy to find the hashed data and also avoid data duplication. Hashing is a fast, efficient way to keep huge troves of data safe, and to ensure its integrity.

How does hashing work?

An algorithm generates hash values, also known as hash functions. The hashing algorithms provide different hash values for different keys. So one unique input string should have a unique hash value.

However, there are rare cases when keys use identical hash values. This can result in the so-called hash collision.

A defining feature of any hashing algorithm is how collision-resistant its hash functions are. Collision is a hash-function vulnerability that bad actors can potentially exploit, so a good hashing algorithm should be complex enough to avoid collisions.

What is encryption?

Encryption is the process of encoding data using algorithm. Encryption protocols scramble the data, so it becomes undecipherable to anyone except the intended recipient, who has the necessary key to reverse the decryption process. Unlike hashing, encryption is a two-way process — information is encrypted and then decrypted when it reaches the intended receiver.

Encryption also secures sensitive data as well as general online traffic. It should make your internet traffic indecipherable to interceptors — smart encryption algorithms are almost impossible to crack without the necessary key.

Hashing vs. encryption

So what is the difference between hashing and encryption? While both hashing and encryption protect your data from rogue external interventions, there are also significant differences between them:

  • Hashing is one-way, while encryption is two-way. Encryption turns plain text into ciphertext, which is unreadable, but you can decrypt it with a relevant key. Hashing scrambles a plain text into a unique encoded hash unit, which can't be reverted into a readable form.
  • Hashing is usually used to ensure the integrity of data, primarily when we’re storing large amounts of it, while encryption is aimed more at protecting the privacy of small amounts of data while in transit;

The most common hashing algorithms

Similarly to encryption, hashing can have various algorithms that differ in their strength:

  • MD5. MD5 emerged as an improvement on the MD4 protocol, which had significant security flaws. While it is still used, other hashing functions are usually preferable due to flaws in its design. Moreover, its 128-bit strength is not enough for proper protection. It's also not very resistant to collisions, so it is not suitable when a cryptography hash is required.
  • SHA. SHA was developed by the National Security Agency back in 1993. Its original version had many flaws, so SHA has been updated a few times. Its later iterations are now widely used for cryptographic purposes. Due to its sensitive hash strings, it is considered to be a fairly secure protocol.
  • BLAKE3. BLAKE3 is the most recent version of the BLAKE hash function. Overall, it performs much better than SHA and BLAKE2 protocols. BLAKE3 is used for Wireguard, an ultra-fast VPN protocol.

Examples of hash usage

Here are some examples of hash usage:

  • Preserves file integrity during file sharing, downloading, or mirroring processes. It ensures that the files you get are intact and have not been tampered with.
  • Digital signatures almost always require the calculation of a cryptographic hash. It guarantees the efficiency and security of digital signature schemes.
  • Password verification commonly uses cryptographic hashes. Hash digests prevent passwords from being compromised. During the user authentication process, a system will compare the a user-entered password's hashes with its own stored values.
  • Hashing is used in cryptocurrency systems to protect them from DDoS attacks and other abuses.
  • We can also use hashing for file identification. This protects users from forgery and cases when they can receive other data than expected.

Example of encryption usage

And here are a few common use-cases for encryption:

  • Encryption is used to protect your online traffic from interventions and snooping. It is one of the essential features of VPN services and online security in general.
  • End-to-end encryption is used in instant messaging services to protect the privacy of your conversations.
  • File encryption protects your files so that no one can access them even if they intercept the files in transit.
  • Encryption protects you from cybercriminals. For example, it is extremely useful on public Wi-Fi networks, which are often popular with hackers.

Online security starts with a click.

Stay safe with the world’s leading VPN