Hash

A hash is a function that converts one value to another. Hashing data is a common practice in computer science and is used for several different purposes. Examples include cryptography, compression, checksum generation, and data indexing.

Hashing is a natural fit for cryptography because it masks the original data with another value. A hash function can be used to generate a value that can only be decoded by looking up the value from a hash table. The table may be an array, database, or other data structure. A good cryptographic hash function is non-invertible, meaning it cannot be reverse engineered.

Since hashed values are generally smaller than the originals, it is possible for a hash function to generate duplicate hashed values. These are known as "collisions" and occur when identical values are produced from different source data. Collisions can be resolved by using multiple hash functions or by creating an overflow table when duplicate hashed values are encountered. Collisions can be avoided by using larger hash values.

Different types of compression, such as lossy image compression and media compression, may incorporate hash functions to reduce file size. By hashing data into smaller values, media files can be compressed into smaller chunks. This type of one-way hashing cannot be reversed, but it can produce an approximation of the original data that requires less disk space.

Hashes are also used to create checksums, which validate the integrity of files. A checksum is a small value that is generated based on the bits in a file or block of data such as a disk image. When the checksum function is run on a copy of the file (such as a file downloaded from the Internet), it should produce the same hashed value as the original file. If the file does not produce the same checksum, something in the file was changed.

Finally, hashes are used to index data. Hashing values can be used to map data to individual "buckets" within a hash table. Each bucket has a unique ID that serves as a pointer to the original data. This creates an index that is significantly smaller than the original data, allowing the values to be searched and accessed more efficiently.

Updated April 21, 2018

Definitions by TechTerms.com

The definition of Hash on this page is an original TechTerms.com definition. If you would like to reference this page or cite this definition, you can use the green citation links above.

The goal of TechTerms.com is to explain computer terminology in a way that is easy to understand. We strive for simplicity and accuracy with every definition we publish. If you have feedback about the Hash definition or would like to suggest a new technical term, please contact us.

Want to learn more tech terms? Subscribe to the daily or weekly newsletter and get featured terms and quizzes delivered to your inbox.

Sign up for the free TechTerms Newsletter

How often would you like to receive an email?

You can unsubscribe or change your frequency setting at any time using the links available in each email.

Questions? Please contact us.