.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings.  \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote.  \*(C+ will
.\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
.\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
.    ds -- \(*W-
.    ds PI pi
.    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
.    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
.    ds L" ""
.    ds R" ""
.    ds C` ""
.    ds C' ""
'br\}
.el\{\
.    ds -- \|\(em\|
.    ds PI \(*p
.    ds L" ``
.    ds R" ''
.    ds C`
.    ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\"
.\" If the F register is >0, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD.  Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{\
.    if \nF \{\
.        de IX
.        tm Index:\\$1\t\\n%\t"\\$2"
..
.        if !\nF==2 \{\
.            nr % 0
.            nr F 2
.        \}
.    \}
.\}
.rr rF
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear.  Run.  Save yourself.  No user-serviceable parts.
.    \" fudge factors for nroff and troff
.if n \{\
.    ds #H 0
.    ds #V .8m
.    ds #F .3m
.    ds #[ \f1
.    ds #] \fP
.\}
.if t \{\
.    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
.    ds #V .6m
.    ds #F 0
.    ds #[ \&
.    ds #] \&
.\}
.    \" simple accents for nroff and troff
.if n \{\
.    ds ' \&
.    ds ` \&
.    ds ^ \&
.    ds , \&
.    ds ~ ~
.    ds /
.\}
.if t \{\
.    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
.    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
.    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
.    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
.    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
.    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
.    \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
.    \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
.    \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
.    ds : e
.    ds 8 ss
.    ds o a
.    ds d- d\h'-1'\(ga
.    ds D- D\h'-1'\(hy
.    ds th \o'bp'
.    ds Th \o'LP'
.    ds ae ae
.    ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "OPENSSL-DGST 1ossl"
.TH OPENSSL-DGST 1ossl "2026-01-27" "3.5.5" "OpenSSL"
.\" For nroff, turn off justification.  Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
openssl\-dgst \- perform digest operations
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
\&\fBopenssl\fR \fBdgst\fR|\fIdigest\fR
[\fB\-\f(BIdigest\fB\fR]
[\fB\-list\fR]
[\fB\-help\fR]
[\fB\-c\fR]
[\fB\-d\fR]
[\fB\-debug\fR]
[\fB\-hex\fR]
[\fB\-binary\fR]
[\fB\-xoflen\fR \fIlength\fR]
[\fB\-r\fR]
[\fB\-out\fR \fIfilename\fR]
[\fB\-sign\fR \fIfilename\fR|\fIuri\fR]
[\fB\-keyform\fR \fB\s-1DER\s0\fR|\fB\s-1PEM\s0\fR|\fBP12\fR|\fB\s-1ENGINE\s0\fR]
[\fB\-passin\fR \fIarg\fR]
[\fB\-verify\fR \fIfilename\fR]
[\fB\-prverify\fR \fIfilename\fR]
[\fB\-signature\fR \fIfilename\fR]
[\fB\-sigopt\fR \fInm\fR:\fIv\fR]
[\fB\-hmac\fR \fIkey\fR]
[\fB\-mac\fR \fIalg\fR]
[\fB\-macopt\fR \fInm\fR:\fIv\fR]
[\fB\-fips\-fingerprint\fR]
[\fB\-engine\fR \fIid\fR]
[\fB\-engine_impl\fR \fIid\fR]
[\fB\-rand\fR \fIfiles\fR]
[\fB\-writerand\fR \fIfile\fR]
[\fB\-provider\fR \fIname\fR]
[\fB\-provider\-path\fR \fIpath\fR]
[\fB\-provparam\fR \fI[name:]key=value\fR]
[\fB\-propquery\fR \fIpropq\fR]
[\fIfile\fR ...]
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
This command output the message digest of a supplied file or files
in hexadecimal, and also generates and verifies digital
signatures using message digests.
.PP
The generic name, \fBopenssl dgst\fR, may be used with an option specifying the
algorithm to be used.
The default digest is \fBsha256\fR.
A supported \fIdigest\fR name may also be used as the sub-command name.
To see the list of supported algorithms, use \f(CW\*(C`openssl list \-digest\-algorithms\*(C'\fR
.SH "OPTIONS"
.IX Header "OPTIONS"
.IP "\fB\-help\fR" 4
.IX Item "-help"
Print out a usage message.
.IP "\fB\-\f(BIdigest\fB\fR" 4
.IX Item "-digest"
Specifies name of a supported digest to be used. See option \fB\-list\fR below :
.IP "\fB\-list\fR" 4
.IX Item "-list"
Prints out a list of supported message digests.
.IP "\fB\-c\fR" 4
.IX Item "-c"
Print out the digest in two digit groups separated by colons, only relevant if
the \fB\-hex\fR option is given as well.
.IP "\fB\-d\fR, \fB\-debug\fR" 4
.IX Item "-d, -debug"
Print out \s-1BIO\s0 debugging information.
.IP "\fB\-hex\fR" 4
.IX Item "-hex"
Digest is to be output as a hex dump. This is the default case for a \*(L"normal\*(R"
digest as opposed to a digital signature.  See \s-1NOTES\s0 below for digital
signatures using \fB\-hex\fR.
.IP "\fB\-binary\fR" 4
.IX Item "-binary"
Output the digest or signature in binary form.
.IP "\fB\-xoflen\fR \fIlength\fR" 4
.IX Item "-xoflen length"
Set the output length for \s-1XOF\s0 algorithms, such as \fBshake128\fR and \fBshake256\fR.
This option is not supported for signing operations.
.Sp
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.
.Sp
To ensure the maximum security strength of 128 bits, the xoflen for \fBshake128\fR
should be set to at least 32 (bytes). For compatibility with previous versions
of OpenSSL, it may be set to 16, resulting in a security strength of only 64
bits.
.Sp
To ensure the maximum security strength of 256 bits, the xoflen for \fBshake256\fR
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.
.IP "\fB\-r\fR" 4
.IX Item "-r"
Output the digest in the \*(L"coreutils\*(R" format, including newlines.
Used by programs like \fBsha1sum\fR\|(1).
.IP "\fB\-out\fR \fIfilename\fR" 4
.IX Item "-out filename"
Filename to output to, or standard output by default.
.IP "\fB\-sign\fR \fIfilename\fR|\fIuri\fR" 4
.IX Item "-sign filename|uri"
Digitally sign the digest using the given private key.
.Sp
Note that for algorithms that only support one-shot signing
(such as Ed25519, \s-1ED448, ML\-DSA\-44, ML\-DSA\-65\s0 andML\-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.
.IP "\fB\-keyform\fR \fB\s-1DER\s0\fR|\fB\s-1PEM\s0\fR|\fBP12\fR|\fB\s-1ENGINE\s0\fR" 4
.IX Item "-keyform DER|PEM|P12|ENGINE"
The format of the key to sign with; unspecified by default.
See \fBopenssl\-format\-options\fR\|(1) for details.
.IP "\fB\-sigopt\fR \fInm\fR:\fIv\fR" 4
.IX Item "-sigopt nm:v"
Pass options to the signature algorithm during sign or verify operations.
Names and values of these options are algorithm-specific and documented
in \*(L"Signature parameters\*(R" in \fBprovider\-signature\fR\|(7).
.IP "\fB\-passin\fR \fIarg\fR" 4
.IX Item "-passin arg"
The private key password source. For more information about the format of \fIarg\fR
see \fBopenssl\-passphrase\-options\fR\|(1).
.IP "\fB\-verify\fR \fIfilename\fR" 4
.IX Item "-verify filename"
Verify the signature using the public key in \*(L"filename\*(R".
The output is either \*(L"Verified \s-1OK\*(R"\s0 or \*(L"Verification Failure\*(R".
.IP "\fB\-prverify\fR \fIfilename\fR" 4
.IX Item "-prverify filename"
Verify the signature using the private key in \*(L"filename\*(R".
.IP "\fB\-signature\fR \fIfilename\fR" 4
.IX Item "-signature filename"
The actual signature to verify.
.IP "\fB\-hmac\fR \fIkey\fR" 4
.IX Item "-hmac key"
Create a hashed \s-1MAC\s0 using \*(L"key\*(R".
.Sp
The \fBopenssl\-mac\fR\|(1) command should be preferred to using this command line
option.
.IP "\fB\-mac\fR \fIalg\fR" 4
.IX Item "-mac alg"
Create \s-1MAC\s0 (keyed Message Authentication Code). The most popular \s-1MAC\s0
algorithm is \s-1HMAC\s0 (hash-based \s-1MAC\s0), but there are other \s-1MAC\s0 algorithms
which are not based on hash, for instance \fBgost-mac\fR algorithm,
supported by the \fBgost\fR engine. \s-1MAC\s0 keys and other options should be set
via \fB\-macopt\fR parameter.
.Sp
The \fBopenssl\-mac\fR\|(1) command should be preferred to using this command line
option.
.IP "\fB\-macopt\fR \fInm\fR:\fIv\fR" 4
.IX Item "-macopt nm:v"
Passes options to \s-1MAC\s0 algorithm, specified by \fB\-mac\fR key.
Following options are supported by both by \fB\s-1HMAC\s0\fR and \fBgost-mac\fR:
.RS 4
.IP "\fBkey\fR:\fIstring\fR" 4
.IX Item "key:string"
Specifies \s-1MAC\s0 key as alphanumeric string (use if key contain printable
characters only). String length must conform to any restrictions of
the \s-1MAC\s0 algorithm for example exactly 32 chars for gost-mac.
.IP "\fBhexkey\fR:\fIstring\fR" 4
.IX Item "hexkey:string"
Specifies \s-1MAC\s0 key in hexadecimal form (two hex digits per byte).
Key length must conform to any restrictions of the \s-1MAC\s0 algorithm
for example exactly 32 chars for gost-mac.
.RE
.RS 4
.Sp
The \fBopenssl\-mac\fR\|(1) command should be preferred to using this command line
option.
.RE
.IP "\fB\-fips\-fingerprint\fR" 4
.IX Item "-fips-fingerprint"
Compute \s-1HMAC\s0 using a specific key for certain OpenSSL-FIPS operations.
.IP "\fB\-rand\fR \fIfiles\fR, \fB\-writerand\fR \fIfile\fR" 4
.IX Item "-rand files, -writerand file"
See \*(L"Random State Options\*(R" in \fBopenssl\fR\|(1) for details.
.IP "\fB\-engine\fR \fIid\fR" 4
.IX Item "-engine id"
See \*(L"Engine Options\*(R" in \fBopenssl\fR\|(1).
This option is deprecated.
.Sp
The engine is not used for digests unless the \fB\-engine_impl\fR option is
used or it is configured to do so, see \*(L"Engine Configuration Module\*(R" in \fBconfig\fR\|(5).
.IP "\fB\-engine_impl\fR \fIid\fR" 4
.IX Item "-engine_impl id"
When used with the \fB\-engine\fR option, it specifies to also use
engine \fIid\fR for digest operations.
.IP "\fB\-provider\fR \fIname\fR" 4
.IX Item "-provider name"
.PD 0
.IP "\fB\-provider\-path\fR \fIpath\fR" 4
.IX Item "-provider-path path"
.IP "\fB\-provparam\fR \fI[name:]key=value\fR" 4
.IX Item "-provparam [name:]key=value"
.IP "\fB\-propquery\fR \fIpropq\fR" 4
.IX Item "-propquery propq"
.PD
See \*(L"Provider Options\*(R" in \fBopenssl\fR\|(1), \fBprovider\fR\|(7), and \fBproperty\fR\|(7).
.IP "\fIfile\fR ..." 4
.IX Item "file ..."
File or files to digest. If no files are specified then standard input is
used.
.SH "EXAMPLES"
.IX Header "EXAMPLES"
To create a hex-encoded message digest of a file:
.PP
.Vb 3
\& openssl dgst \-md5 \-hex file.txt
\& or
\& openssl md5 file.txt
.Ve
.PP
To sign a file using \s-1SHA\-256\s0 with binary file output:
.PP
.Vb 3
\& openssl dgst \-sha256 \-sign privatekey.pem \-out signature.sign file.txt
\& or
\& openssl sha256 \-sign privatekey.pem \-out signature.sign file.txt
.Ve
.PP
To verify a signature:
.PP
.Vb 3
\& openssl dgst \-sha256 \-verify publickey.pem \e
\& \-signature signature.sign \e
\& file.txt
.Ve
.SH "NOTES"
.IX Header "NOTES"
The digest mechanisms that are available will depend on the options
used when building OpenSSL.
The \f(CW\*(C`openssl list \-digest\-algorithms\*(C'\fR command can be used to list them.
.PP
New or agile applications should use probably use \s-1SHA\-256.\s0 Other digests,
particularly \s-1SHA\-1\s0 and \s-1MD5,\s0 are still widely used for interoperating
with existing formats and protocols.
.PP
When signing a file, this command will automatically determine the algorithm
(\s-1RSA, ECC,\s0 etc) to use for signing based on the private key's \s-1ASN.1\s0 info.
When verifying signatures, it only handles the \s-1RSA, DSA,\s0 or \s-1ECDSA\s0 signature
itself, not the related data to identify the signer and algorithm used in
formats such as x.509, \s-1CMS,\s0 and S/MIME.
.PP
A source of random numbers is required for certain signing algorithms, in
particular \s-1ECDSA\s0 and \s-1DSA.\s0
.PP
The signing and verify options should only be used if a single file is
being signed or verified.
.PP
Hex signatures cannot be verified using \fBopenssl\fR.  Instead, use \*(L"xxd \-r\*(R"
or similar program to transform the hex signature into a binary signature
prior to verification.
.PP
The \fBopenssl\-mac\fR\|(1) command is preferred over the \fB\-hmac\fR, \fB\-mac\fR and
\&\fB\-macopt\fR command line options.
.SH "SEE ALSO"
.IX Header "SEE ALSO"
\&\fBopenssl\-mac\fR\|(1)
.SH "HISTORY"
.IX Header "HISTORY"
The default digest was changed from \s-1MD5\s0 to \s-1SHA256\s0 in OpenSSL 1.1.0.
The FIPS-related options were removed in OpenSSL 1.1.0.
.PP
The \fB\-engine\fR and \fB\-engine_impl\fR options were deprecated in OpenSSL 3.0.
.SH "COPYRIGHT"
.IX Header "COPYRIGHT"
Copyright 2000\-2025 The OpenSSL Project Authors. All Rights Reserved.
.PP
Licensed under the Apache License 2.0 (the \*(L"License\*(R").  You may not use
this file except in compliance with the License.  You can obtain a copy
in the file \s-1LICENSE\s0 in the source distribution or at
<https://www.openssl.org/source/license.html>.
