ArticleslgStudy

computer science

Fuzzy hashing

Fuzzy hashing is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Fuzzy hashing rather than just read about it. In short: Fuzzy hashing, also known as similarity hashing, is a technique for detecting data that is similar, but not exactly the same, as other data. This is in contrast to cryptographic hash functions, which are designed to have significantly different hashes for even minor differences.

Key takeaways

  • Fuzzy hashing belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Fuzzy hashing to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Fuzzy hashing from memory before moving on to harder problems.

Reference excerpt

Fuzzy hashing, also known as similarity hashing, is a technique for detecting data that is similar, but not exactly the same, as other data. This is in contrast to cryptographic hash functions, which are designed to have significantly different hashes for even minor differences. Fuzzy hashing has been used to identify malware and has potential for other applications, like data loss prevention and detecting multiple versions of code.

Background A hash function is a mathematical algorithm which maps arbitrary-sized data to a fixed size output. Many solutions use cryptographic hash functions like SHA-256 to detect duplicates or check for known files within large collection of files. However, cryptographic hash functions cannot be used for determining if a file is similar to a known file, because one of the requirements of a cryptographic hash function is that a small change to the input should change the hash value so extensively that the new hash value appears uncorrelated with the old hash value (avalanche effect). Fuzzy hashing exists to solve this problem of detecting data that is similar, but not exactly the same, as other data. Fuzzy hashing algorithms specifically use algorithms in which two similar inputs will generate two similar hash values. This property is the exact opposite of the avalanche effect desired in cryptographic hash functions. Fuzzy hashing can also be used to detect when one object is contained within another.

Approaches There are a few approaches used for building fuzzy hash algorithms:

Context-triggered piecewise hashing (CTPH), which constructs a hash by splitting the input into multiple pieces, calculating traditional hashes for each piece, and then combining those traditional hashes into a single string. Locality-sensitive hashing places similar input items into the same "buckets", which can be used for data clustering and nearest neighbor searches.

Notable tools and algorithms spamsum is a tool written by Andrew Tridgell that uses fuzzy hashing to determine whether an email is similar to known spam. It operates by generating a fuzzy hash for an email that it compares against the fuzzy hashes from known spam emails to generate a match result between 0 (complete mismatch) to 100 (perfect match). If the match result is high enough, the email is classified as spam. Nilsimsa Hash is an anti-spam–focused locality-sensitive hashing algorithm. ssdeep is a fuzzy hashing tool based on context-triggered piecewise hashing to compare files. sdhash is a fuzzy hashing tool based on using Bloom filters to determine whether one file is contained within another or how similar two files are to each other. TLSH is a locality-sensitive hashing scheme for comparing whether files are similar to each other. It has been used for malware clustering. Rspamd uses fuzzy hashing to detect spam emails, using the shingles algorithm for this purpose.

See also Checksum § Fuzzy checksum

References

Worked examples

Example 1 — a first encounter with Fuzzy hashing

Start with the simplest possible case. Write down what Fuzzy hashing claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Fuzzy hashing before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Fuzzy hashing ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Fuzzy hashing

In research
Fuzzy hashing appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Fuzzy hashing in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Fuzzy hashing is common in secondary-school and first-year university syllabi. It links to neighbouring topics Anti-spam, Computer security, Digital forensics, so understanding it makes those chapters shorter.
In everyday life
Look for Fuzzy hashing outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Fuzzy hashing in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Fuzzy hashing means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Fuzzy hashing out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Fuzzy hashing in simple terms?

Fuzzy hashing, also known as similarity hashing, is a technique for detecting data that is similar, but not exactly the same, as other data. This is in contrast to cryptographic hash functions, which are designed to have significantly different hashes for even minor differences.

Why does Fuzzy hashing matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Fuzzy hashing?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Fuzzy hashing.

Tags

  • Anti-spam
  • Computer security
  • Digital forensics
  • Hashing

Keep exploring