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 by Per C.

quizTest Your Knowledge

SQL is used to access and modify data from what type of source?

A
FTP servers
0%
B
Government websites
0%
C
Relational databases
0%
D
Log files
0%
Correct! Incorrect!     View the SQL definition.
More Quizzes →

The Tech Terms Computer Dictionary

The definition of Hash on this page is an original definition written by the TechTerms.com team. If you would like to reference this page or cite this definition, please 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 this definition or would like to suggest a new technical term, please contact us.

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.