OPENSSL-DGST(1ossl)

πŸ’… OPENSSL-DGST β€” the dgst / digest page, bestie edition ✨

okay so you're looking at the 1ossl manual for openssl-dgst, and honestly? it's a good one. let's get into it 🫢


🌸 NAME 🌸

openssl-dgst β€” literally just here to perform digest operations. that's the whole job. icon behavior.


✨ SYNOPSIS ✨

openssl dgst|digest [-digest] [-list] [-help] [-c] [-d] [-debug] [-hex]
[-binary] [-xoflen length] [-r] [-out filename] [-sign filename|uri]
[-keyform DER|PEM|P12|ENGINE] [-passin arg] [-verify filename]
[-prverify filename] [-signature filename] [-sigopt nm:v] [-hmac key]
[-mac alg] [-macopt nm:v] [-fips-fingerprint] [-engine id] [-engine_impl
id] [-rand files] [-writerand file] [-provider name] [-provider-path
path] [-provparam [name:]key=value] [-propquery propq] [file ...]

πŸ¦‹ DESCRIPTION πŸ¦‹

So. This command outputs the message digest of a file (or several files, she's flexible πŸ’…) in hexadecimal β€” and it also generates and verifies digital signatures using message digests. multitasking queen.

The generic name, openssl dgst, can be used together with an option that says which algorithm you want. The default digest is sha256. You can also just use a supported digest name as the sub-command name itself, which is lowkey the cute shortcut. To see the list of supported algorithms, run openssl list -digest-algorithms.


πŸŽ€ OPTIONS πŸŽ€

  • -help β€” prints out a usage message. the classic "wait what do I do" button.
  • -digest β€” specifies the name of a supported digest to use. See option -list below : (yes the colon is staying, it's part of the vibe).
  • -list β€” prints out a list of supported message digests. window shopping for algorithms ✨
  • -c β€” prints the digest in two digit groups separated by colons. only relevant if you also gave the -hex option. it's giving "organized little hex nuggets".
  • -d, -debug β€” prints out BIO debugging information. nosy on purpose πŸ’€
  • -hex β€” the digest gets output as a hex dump. this is the default case for a "normal" digest, as opposed to a digital signature. see NOTES below for digital signatures using -hex.
  • -binary β€” outputs the digest or signature in binary form. raw bytes, no filter πŸ¦‹
  • -xoflen length β€” sets the output length for XOF algorithms, like shake128 and shake256. this option is not supported for signing operations.

For OpenSSL providers it is required to set this value for shake algorithms, since the previous default values were only set to supply half of the maximum security strength.

To ensure the maximum security strength of 128 bits, the xoflen for shake128 should be set to at least 32 (bytes). For compatibility with previous versions of OpenSSL, it may be set to 16, which results in a security strength of only 64 bits. so like… yes you can, but bestie 😭

To ensure the maximum security strength of 256 bits, the xoflen for shake256 should be set to at least 64 (bytes). For compatibility with previous versions of OpenSSL, it may be set to 32, resulting in a security strength of only 128 bits.

  • -r β€” outputs the digest in the "coreutils" format, including newlines. used by programs like sha1sum(1). she's interoperable πŸ’–
  • -out filename β€” filename to output to, or standard output by default.
  • -sign filename|uri β€” digitally signs the digest using the given private key.
heads up bestie: for algorithms that only support one-shot signing (such as Ed25519, ED448, ML-DSA-44, ML-DSA-65 and ML-DSA-87) the digest must not be set. For these algorithms the input is buffered (and not digested) before signing. For these algorithms, if the input is larger than 16MB an error will occur.
  • -keyform DER|PEM|P12|ENGINE β€” the format of the key to sign with; unspecified by default. see openssl-format-options(1) for the details.
  • -sigopt nm:v β€” passes options to the signature algorithm during sign or verify operations. the names and values of these options are algorithm-specific and documented in "Signature parameters" in provider-signature(7).
  • -passin arg β€” the private key password source. for more info about the format of arg see openssl-passphrase-options(1). 🀫
  • -verify filename β€” verifies the signature using the public key in filename. the output is either Verified OK or Verification Failure. no in-between, no "it's complicated".
  • -prverify filename β€” verifies the signature using the private key in filename.
  • -signature filename β€” the actual signature to verify. like, the thing itself.
  • -hmac key β€” creates a hashed MAC using key.
the openssl-mac(1) command should be preferred to using this command line option.
  • -mac alg β€” creates a MAC (keyed Message Authentication Code). the most popular MAC algorithm is HMAC (hash-based MAC), but there are other MAC algorithms that aren't based on hash β€” for instance the gost-mac algorithm, supported by the gost engine. MAC keys and other options should be set via the -macopt parameter.
again: the openssl-mac(1) command should be preferred to using this command line option.
  • -macopt nm:v β€” passes options to the MAC algorithm, specified by -mac key. the following options are supported by both HMAC and gost-mac:
    • key:string β€” specifies the MAC key as an alphanumeric string (use this if the key contains printable characters only). the string length must conform to any restrictions of the MAC algorithm β€” for example exactly 32 chars for gost-mac.
    • hexkey:string β€” specifies the MAC key in hexadecimal form (two hex digits per byte). the key length must conform to any restrictions of the MAC algorithm β€” for example exactly 32 chars for gost-mac.
and one more time for the people in the back: the openssl-mac(1) command should be preferred to using this command line option. 🫢
  • -fips-fingerprint β€” computes HMAC using a specific key for certain OpenSSL-FIPS operations.
  • -rand files, -writerand file β€” see "Random State Options" in openssl(1) for the details.
  • -engine id β€” see "Engine Options" in openssl(1). this option is deprecated πŸ’€

The engine is not used for digests unless the -engine_impl option is used, or it's configured to do so β€” see "Engine Configuration Module" in config(5).

  • -engine_impl id β€” when used with the -engine option, it specifies to also use engine id for digest operations.
  • -provider name, -provider-path path, -provparam [name:]key=value, -propquery propq β€” see "Provider Options" in openssl(1), provider(7), and property(7).
  • file ... β€” file or files to digest. if no files are specified, then standard input is used. stdin said "I got this" πŸ’…

🌈 EXAMPLES 🌈

To create a hex-encoded message digest of a file:

openssl dgst -md5 -hex file.txt
or
openssl md5 file.txt

To sign a file using SHA-256 with binary file output:

openssl dgst -sha256 -sign privatekey.pem -out signature.sign file.txt
or
openssl sha256 -sign privatekey.pem -out signature.sign file.txt

To verify a signature:

openssl dgst -sha256 -verify publickey.pem \
-signature signature.sign \
file.txt

ate. no crumbs. πŸ”₯


🧚 NOTES 🧚

The digest mechanisms available will depend on the options used when building OpenSSL. The openssl list -digest-algorithms command can be used to list them.

New or agile applications should use probably use SHA-256. (yes that double "use" is in the original, we don't fix, we respect ✨) Other digests, particularly SHA-1 and MD5, are still widely used for interoperating with existing formats and protocols.

When signing a file, this command will automatically determine the algorithm (RSA, ECC, etc) to use for signing, based on the private key's ASN.1 info. She's smart like that. When verifying signatures, it only handles the RSA, DSA, or ECDSA signature itself β€” not the related data that identifies the signer and algorithm used in formats such as x.509, CMS, and S/MIME.

A source of random numbers is required for certain signing algorithms, in particular ECDSA and DSA. 🎲

The signing and verify options should only be used if a single file is being signed or verified. one file, one vibe check.
Hex signatures cannot be verified using openssl. instead, use xxd -r or a similar program to transform the hex signature into a binary signature prior to verification. you've been warned bestie 😭

The openssl-mac(1) command is preferred over the -hmac, -mac and -macopt command line options. (third time's the charm πŸ’–)


πŸ‘‘ SEE ALSO πŸ‘‘


πŸ“ HISTORY πŸ“

The default digest was changed from MD5 to SHA256 in OpenSSL 1.1.0. The FIPS-related options were removed in OpenSSL 1.1.0.

The -engine and -engine_impl options were deprecated in OpenSSL 3.0.


Copyright 2000-2025 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.


and that's the whole page, bestie 🫢 this was version 3.5.9, dated 2026-09-29, filed under OPENSSL-DGST(1ossl) β€” go forth and digest, ily β­πŸ’…

πŸ“¦ where this page comes from