AI Glossary / AI and machine learning / Intermediate

Hashing

Definition

Hashing is the conversion of data of any size into a fixed-length code, called a hash, so that items can be stored, compared, retrieved or anonymized quickly and consistently.

What it means

A hash function is a relentless summarizer: feed it a word, a file or a customer record and it returns a fixed-length code, the same code every time for the same input. That consistency is the whole point.

Hashes serve several distinct jobs. They give fast lookup, since a fixed code indexes better than a sprawling record; they detect change, since any edit alters the hash; and they disguise data, since a good hash cannot be reversed into the original.

In machine learning, hashing compresses enormous vocabularies into manageable tables: millions of possible words or categories are mapped into a fixed number of buckets, trading a few collisions for vast savings in memory and speed.

Hashing is not encryption. Encryption is meant to be undone with a key; hashing is meant to be one-way, and anonymization built on weak hashing can be undone by anyone who guesses the likely inputs and hashes them.

For a business, hashing shows up quietly everywhere: deduplicating records, checking file integrity, pseudonymizing customer identifiers and compressing features. It is basic plumbing with real consequences when chosen carelessly.

How it works

Choose the hash function for the job: fast non-cryptographic hashes for lookup and features, slow salted cryptographic hashes for secrets and identifiers.

Apply the same function and settings everywhere a given comparison is needed, because two different hashes of the same record are just two numbers.

Handle collisions according to the stakes: accept them in feature compression, detect and resolve them in deduplication.

Add a salt, a secret random value, when hashing identifiers, so attackers cannot simply pre-hash a list of likely names or emails.

Record which function, version and salt regime produced each stored hash, since re-hashing history is nobody's favorite project.

Three practical examples

  • A retailer deduplicating its customer file by hashing name, address and birth date combinations, catching half a million double-counted customers.
  • A data team hashing email addresses before sharing a marketing extract with an outside agency, so raw addresses never leave the building.
  • A text model using the hashing trick to squeeze a million-word vocabulary into 100,000 feature columns without a stored dictionary.

Think of it this way

Think of a fingerprint: a fixed-size pattern derived from a person, quick to compare, useless for reconstructing the person, and the same every time you take it. A hash is a fingerprint for data, with the same strengths and the same limit: it identifies, it does not describe.

The limit: fingerprints of a small suspect list are easy to search. If the possible inputs are few, phone numbers, say, anyone can hash them all and match, which is why hashes of guessable data are pseudonyms, not anonymization.

Worked example

spotting silent file corruption

Suppose a finance team transfers a reconciliation file nightly between two systems. The figures are illustrative.

Each side computes the file's hash and the pair is compared automatically; matching hashes mean the file arrived intact.

One night the hashes differ: a transfer retry had appended a partial duplicate block, invisible to row counts that only checked the header.

The hash check cost a line of code and caught a class of error that had previously surfaced as month-end mysteries.

Illustrative case study

A fictional health provider anonymized a research extract by hashing patient phone numbers, and a consultant re-identified half the file in an afternoon by hashing the national number range and matching.

The provider had published the extract as anonymized, and the episode became a regulator finding rather than a research triumph.

The invented lesson: a hash of guessable data is a disguise, not a protection. Salt it, key it, or do not call it anonymized.

Common misconceptions and mistakes

  • Hashing makes data anonymous. It makes it pseudonymous at best; guessable inputs can be re-identified by hashing and matching, unless the hash is salted or keyed.
  • Hashing and encryption are interchangeable. Encryption is reversible with a key by design; hashing is one-way by design, and each has jobs the other cannot do well.
  • Collisions mean the hash is broken. Collisions are expected at scale; good practice budgets for them and handles them deliberately.

Business use

Standardize hash functions and salt regimes across systems, or reconciliation and matching quietly fail at the joins.

Never publish hashes of low-variety identifiers such as phone or national ID numbers; treat them as the identifiers they still are.

Use hashes deliberately in ML features to control memory, and measure the small accuracy cost of collisions rather than discovering it.

People also ask

What is a hash collision?

Two different inputs producing the same code; inevitable in principle, rare with good functions, and handled by design where it matters.

Is a hashed password safe?

Only if a slow, salted password hash was used; fast general-purpose hashes fall to guessing attacks quickly.

What is the hashing trick in machine learning?

Mapping features into a fixed number of buckets by hash, avoiding a stored vocabulary and bounding memory, at the cost of some collisions.

Check your understanding

Why is a hash of a phone number not true anonymization?

Answer: Because the space of phone numbers is small enough to enumerate, so anyone can hash every candidate and match the outputs, reversing the disguise without breaking the hash itself.

Related terms

  • Feature hashing
  • Data integrity
  • encryption
  • pseudonymisation
  • salting
  • deduplication

Learn next

AI Agents and Automation for Small Business covers safe data-handling patterns for automated workflows, including when disguised data is still sensitive: https://aiforbusinessandlife.com/academy/ai-agents-automation-small-business. [C4]

More in AI and machine learning

  • Handwriting recognition - Handwriting recognition is the process of converting handwritten marks into machine-readable text or symbols.
  • Hannan - Quinn information criterion - The Hannan - Quinn information criterion is a score for comparing statistical models that balances goodness of fit against model complexity.
  • Hard clustering - Hard clustering is clustering where every item belongs to exactly one cluster, with no partial or shared membership: each customer, document or transaction...
  • Hidden Markov Decision Tree - A Hidden Markov Decision Tree is a hybrid model that grows a decision tree over sequential data, with hidden states at the nodes, so that each branch of the...
  • Hidden Markov Model with Duration - A Hidden Markov Model with Duration is a sequence model that extends the classic hidden Markov model by explicitly modeling how long the system stays in...
  • Hidden Markov random field - A Hidden Markov random field is a model for data arranged in a grid or network, most often images, where hidden labels at each location depend on their...

Sources

[S2] Google, Machine Learning Glossary. Full URLs are in the source ledger. Verified 11 October 2026.

Previous: Hash join Next: Hashtag

  • Home
  • Daily AI Updates
  • Blog
  • AIFBL Academy
  • AI Glossary
  • Products and Tools
  • Store
  • Free CFO AI Prompt Pack
  • About Shihan Sheriff
  • Privacy Policy
  • Terms of Use
  • Refund Policy
  • Cookie Policy
  • Earnings Disclaimer