101

I was wondering about the difference between these two terms... What is the difference between a digest and a hash function?

Mike Edward Moras
  • 18,161
  • 12
  • 87
  • 240
Francesco Mari
  • 1,121
  • 2
  • 7
  • 7

3 Answers3

115

The digest is the output of the hash function.

For example, sha256 has a digest of 256 bits, i.e. its digest has a length of 32 bytes.

That's it really.

Mike Edward Moras
  • 18,161
  • 12
  • 87
  • 240
Awn
  • 1,632
  • 1
  • 15
  • 18
26

The basic difference between a hash function and digest is that digest is the value obtained from a hash function.

A hash function is any function that can be used to map data of arbitrary size to data of fixed size. The values returned by a hash function are called hash values, hash codes, digests, or simply hashes.

One use is a data structure called a hash function, widely used in computer software for rapid data lookup. For example, suppose that you want to count the number of occurrences of the alphabets in a string.

Always remember that the hash digest returns an alphanumeric message which is the digest. Also,the hash function tries to map large data of variable length to a fixed length data.

Biv
  • 10,088
  • 2
  • 42
  • 68
Shanif Ansari
  • 369
  • 2
  • 2
3

The terminology is used a little loosely, but I would characterize a "digest" as intended to be unique, so that if any pair of documents produce the same digest, they are almost certainly identical. Hash functions are only intended to split the input into a set of equivalence classes, where most but not all pairs of documents will have different hashes.

ddyer
  • 509
  • 3
  • 5