Length Never Changes
The length of a digest belongs to the hash function and not to the message; SHA-256 always gives 32 bytes, other functions give other lengths, and SHAKE128 gives as many bytes as you ask for.
The question
The digest of a three-byte message has 32 bytes, and so has the digest of a message of three megabytes. Is that a property of SHA-256 only, or of every hash function? And is there a hash function whose output length is not fixed?
This matters because a digest is often used as a name or an identifier. A name of fixed length, whatever it names, can be stored in a field of fixed size.
Work it by hand
FIPS 180-4 section 6.2 defines SHA-256 with a message digest of 256 bits, which is 32 bytes, for every message. FIPS 180-4 defines SHA-512 in section 6.4 and SHA-384 in section 6.5, and FIPS 202 section 6.1 defines SHA3-256 with the same 256 bits as SHA-256 by another construction. In each case the length is a number chosen in the definition of the function. The message only changes the bytes, never the count.
FIPS 202 section 6.2 defines two functions that behave differently: SHAKE128 and SHAKE256 are extendable-output functions, written SHAKE128(M, d) "for any output length d". The caller chooses d. Measured with the text of the demo below: asking for 3 bytes gives 1b3dac, the first 3 bytes of the 16 bytes that begin 1b3dac14.
Run it
The command below computes SHAKE128 of the text in in/message.txt and asks for 16 bytes with -xoflen 16. The option -binary writes the raw bytes and -out out.bin names the file. The picture shows the message, the 16 bytes and their count. You can change the text, and you can change the number after -xoflen: a positive number up to at least 20000 ran when measured, and the file then holds that many bytes.

# SHAKE128 gives as many bytes as the caller asks for.
# in/message.txt holds the text; the bytes go to out.bin.
openssl dgst -shake128 -xoflen 16 -binary -out out.bin in/message.txt
{
"answer": "1b3dac14ff461fef2439e88b3979fbf8",
"file": "out.bin",
"bytes": 16
}Two edits stop the command. Without -xoflen the page shows the reason "OpenSSL: unsupported": SHAKE128 has no fixed length for the command to use. With -xoflen 0 it shows dgst: Non-positive number "0" for option -xoflen: unsupported. The program interface refuses SHAKE128 as well: a call ssl.digest("SHAKE128", text) stops with a message that ends Ssl.digest: digest.
Your turn
The program below should return the length of a digest in bytes for a hash function name and a text. It is called with algorithm one of SHA256, SHA384, SHA512, SHA512-256, SHA3-256, MD5, SHA1 and BLAKE2B512, and data a text. Read the program, run it with other names and texts, and judge each length. Check runs it on the data shown and on five others.

let digest = ssl.digest("SHA256", data);
let size = str_len(digest) / 2;
let answer = size;
{
"answer": 32
}Return, as an int, the length in bytes of the digest that ssl.digest gives for the function name algorithm and the text data. The names are SHA256, SHA384, SHA512, SHA512-256, SHA3-256, MD5, SHA1 and BLAKE2B512. Check runs your program with other names and texts, including an empty text and long texts.
Read the result carefully
The program measures the length of the digest that lmssl returns for the name it is given: it does not know the length from a table, and it stops with a message if the name is not one it knows. A name that is not accepted gives a message that ends Ssl.digest: unknown digest 'FOO': error:0308010C:digital envelope routines::unsupported, and SHAKE128 and SHAKE256 are refused because they need a length.
MD5 and SHA-1 appear in the exercise because they have lengths to measure; the page does not recommend any function and says nothing about how well any of them is used. Equal lengths do not mean equal functions: SHA-256 and SHA3-256 both give 32 bytes, so the length alone does not tell you which function made a digest.
Recap
- A fixed-output hash function gives a digest whose length is part of its definition: 32 bytes for SHA-256 and SHA3-256.
- The message changes the bytes of the digest and never their number.
- SHAKE128 and SHAKE256 are extendable-output functions: the caller chooses the output length.
- In a command SHAKE128 needs
-xoflen;ssl.digestin a program refuses it.