37
$\begingroup$

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

$\endgroup$
50
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ Comments are not for extended discussion; this conversation has been moved to chat. $\endgroup$ – e-sushi Sep 2 '17 at 13:41
  • 4
    $\begingroup$ That might be what it means today, but 20+ years ago "message digest algorithm" was simply a synonym for cryptographic hash function. See for example the MD4 RFC which says "...This document describes the MD4 message-digest algorithm ..." $\endgroup$ – James K Polk Sep 2 '17 at 19:51
6
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ Hi, welcome to Crypto.SE, as we speak of cryptography here, we assume that we are talking about cryptographic hash functions. Other hash functions do not interest us and are not in the scope here. Thus one of the use case of hash functions as you defined it (lookup etc) is not our concern. Moreover in this use-case, cryptographic hash functions would be too slow. $\endgroup$ – Biv Sep 2 '17 at 10:16
  • 7
    $\begingroup$ hash digest returns an alphanumeric message which is the digest. that is incorrect, this alphanumeric message is a representation of the digest. The digest itself is a string of bits with a fixed length. $\endgroup$ – Biv Sep 2 '17 at 10:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.