I was wondering about the difference between these two terms... What is the difference between a digest and a hash function?
-
2Digest is the output, in various encodings. – Awn Sep 01 '17 at 11:55
-
1See first paragraph of https://en.wikipedia.org/wiki/Cryptographic_hash_function – Ruggero Sep 01 '17 at 11:55
-
1So, you practically avoided research efforts. Related to that, please note *“How do I ask a good question?”*. In the end I have to agree with @Ruggero – “A cryptographic hash function is a special class of hash function that has certain properties which make it suitable for use in cryptography … the output (the hash value or hash) is often called the message digest or simply the digest.” Next time, try to ask more than a one-liner and at least describe your research efforts. Tnx – e-sushi Sep 02 '17 at 13:38
-
933 people thought this was a good question though. – Константин Ван Jul 02 '19 at 18:32
-
2I think questions like this should absolutely be welcome on Stack Exchange. SE can sometimes provide greater value than something like Wikipedia because of valuable discussion that can happen -- and sometimes there is not exactly one right answer. – rpivovar Mar 18 '21 at 23:01
-
Wikipedia's answer was not clear to this non-expert. Example: two programs give me BLAKE2 outputs of differing length. How to characterize that? Piecing together multiple answers suggests that, perhaps, "The BLAKE 2s hash function (i.e., algorithm) outputs a binary message (i.e., a very long string of 0-or-1 bits) encoded into a hexadecimal message digest (a/k/a hash value) of up to 32 bytes (i.e., 64 characters) in length, while the digest in BLAKE 2b is up to 64 bytes (i.e., 128 characters). A cryptographic hash function must meet additional criteria. See Wikipedia." – Ray Woodcock Jun 19 '22 at 23:08
-
the fact that he accepted the shortest answer proves this was a click-bait question, this should rather be a chat question, Wikipedia's unclear output is not reason to jump on here with google questions – Ed_ Feb 21 '23 at 17:48
3 Answers
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.
-
1Comments are not for extended discussion; this conversation has been moved to chat. – e-sushi Sep 02 '17 at 13:41
-
13That 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 ..." – President James K. Polk Sep 02 '17 at 19:51
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.

- 9,979
- 2
- 39
- 67

- 349
- 1
- 2
-
2Hi, 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. – Biv Sep 02 '17 at 10:16
-
10
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. – Biv Sep 02 '17 at 10:17 -
@Biv in what scenarios can the representation differ from the reality? I can only think of encoding choice. – Aditya M P May 11 '20 at 18:27
-
3@AdityaMP the output of a hash function is a binary data (Blob). You cannot print it out as is to a console, you'd need to encode it to something, e.g. to base64-string. That base64-encoded string is going to be a representation of a Hash. There may be more than one representation of a hash (different String values), but it is still going to be the same digest. – wintermute Apr 03 '21 at 00:52
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.

- 509
- 3
- 5
-
1This conflates general-purpose hash functions as used in e.g. data structures, which do indeed just aim to create 'buckets' of things, with cryptographic hash functions, whose aim it is to not allow finding any two documents with the same hash value. – Morrolan Nov 21 '22 at 09:05
-
i tend to use this distinction as well when naming my variables, but then: my field is usually outside of crypto doing business software. – elonderin Jan 16 '23 at 12:20