Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

A one-way hash function converts an input of any length into a fixed-length value called a hash or digest. Its one-way property means that, given a digest, it should be computationally infeasible to find an input that produces it—not that reversal is logically impossible.

What does “one-way” mean?

A hash function takes an input bit string—such as a file or message—and produces a fixed-length digest. NIST describes hash values as fingerprints of files or electronic messages: a compact value derived from data, not a container holding the original data. The analogy has limits because different inputs can share a digest.

“One-way” refers to computational difficulty. Given a chosen digest, a practical attacker should not be able to find an input that produces it. NIST calls this property preimage resistance. It is a security expectation, not a guarantee that no matching input exists.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How do the three hash security properties differ?

The distinction is what the searcher knows or gets to choose:

Property What the searcher starts with What should be difficult
Preimage resistance A target digest Finding any input that produces that digest
Second-preimage resistance A particular input Finding a different input with the same digest
Collision resistance No fixed input or digest Finding any two distinct inputs with the same digest

These are separate security goals. A collision searcher can choose both inputs, so a collision does not have to involve a preselected message or target digest. NIST defines second-preimage resistance and collision resistance in terms of those different starting conditions.

Can you reverse a hash?

There is no ordinary decryption step that recovers the original input from a digest. If the input came from a limited or predictable set, however, someone can try candidate inputs, hash each one, and compare the results. A match reveals a candidate input; it does not mean the hash function was reversed. For arbitrary inputs, finding a preimage should be computationally infeasible when the function is secure for the application.

Collisions exist in principle: inputs can be of arbitrary length, while the digest has a fixed length and therefore a finite set of possible outputs. The security question is whether an attacker can feasibly find a collision or a preimage, not whether such inputs are mathematically impossible.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Is hashing the same as encryption?

No. A hash function produces a digest and is designed around properties such as preimage and collision resistance. Encryption is used when data must be transformed and later recovered by an authorized party with the appropriate key. Hashing alone does not hide data or provide a way to restore the original message.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What is an example of a one-way hash function?

SHA-256 is a standardized hash function whose full-length output is 256 bits, according to NIST’s 2012 SP 800-107 Rev. 1. SHA-2 and SHA-3 are standardized hash-function families; NIST describes SHA-3 as a permutation-based family specified by FIPS 202 on its Hash Functions project page.

These examples do not make one algorithm suitable for every purpose. NIST’s hash-function policy page encourages SHA-256 at minimum for applications requiring interoperability and addresses SHA-1 in collision-sensitive applications. Check the current policy and the requirements of the specific protocol or application before choosing an algorithm.

What should you remember?

  • A hash maps input of arbitrary length to a fixed-length digest.
  • Preimage resistance concerns finding an input for a chosen digest; second-preimage resistance concerns matching a given input; collision resistance concerns finding any matching pair.
  • “One-way” means computationally difficult to reverse in the relevant security sense—not impossible in mathematics.
  • A digest is not encryption: hashing alone does not conceal data or let you recover it.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.