2 {- OpenSSL::safe::output_do_not_edit_headers(); -}
6 openssl-dgst - perform digest operations
10 B<openssl> B<dgst>|I<digest>
19 [B<-xoflen> I<length>]
22 [B<-sign> I<filename>|I<uri>]
23 [B<-keyform> B<DER>|B<PEM>|B<P12>|B<ENGINE>]
25 [B<-verify> I<filename>]
26 [B<-prverify> I<filename>]
27 [B<-signature> I<filename>]
28 [B<-sigopt> I<nm>:I<v>]
31 [B<-macopt> I<nm>:I<v>]
32 [B<-fips-fingerprint>]
33 {- $OpenSSL::safe::opt_engine_synopsis -}{- output_off() if $disabled{"deprecated-3.0"}; ""
34 -}[B<-engine_impl> I<id>]{-
35 output_on() if $disabled{"deprecated-3.0"}; "" -}
36 {- $OpenSSL::safe::opt_r_synopsis -}
37 {- $OpenSSL::safe::opt_provider_synopsis -}
42 This command output the message digest of a supplied file or files
43 in hexadecimal, and also generates and verifies digital
44 signatures using message digests.
46 The generic name, B<openssl dgst>, may be used with an option specifying the
48 The default digest is B<sha256>.
49 A supported I<digest> name may also be used as the sub-command name.
50 To see the list of supported algorithms, use C<openssl list -digest-algorithms>
58 Print out a usage message.
62 Specifies name of a supported digest to be used. See option B<-list> below :
66 Prints out a list of supported message digests.
70 Print out the digest in two digit groups separated by colons, only relevant if
71 the B<-hex> option is given as well.
73 =item B<-d>, B<-debug>
75 Print out BIO debugging information.
79 Digest is to be output as a hex dump. This is the default case for a "normal"
80 digest as opposed to a digital signature. See NOTES below for digital
81 signatures using B<-hex>.
85 Output the digest or signature in binary form.
87 =item B<-xoflen> I<length>
89 Set the output length for XOF algorithms, such as B<shake128>.
93 =for openssl foreign manual sha1sum(1)
95 Output the digest in the "coreutils" format, including newlines.
96 Used by programs like L<sha1sum(1)>.
98 =item B<-out> I<filename>
100 Filename to output to, or standard output by default.
102 =item B<-sign> I<filename>|I<uri>
104 Digitally sign the digest using the given private key. Note this option
105 does not support Ed25519 or Ed448 private keys. Use the L<openssl-pkeyutl(1)>
106 command instead for this.
108 =item B<-keyform> B<DER>|B<PEM>|B<P12>|B<ENGINE>
110 The format of the key to sign with; unspecified by default.
111 See L<openssl-format-options(1)> for details.
113 =item B<-sigopt> I<nm>:I<v>
115 Pass options to the signature algorithm during sign or verify operations.
116 Names and values of these options are algorithm-specific.
118 =item B<-passin> I<arg>
120 The private key password source. For more information about the format of I<arg>
121 see L<openssl-passphrase-options(1)>.
123 =item B<-verify> I<filename>
125 Verify the signature using the public key in "filename".
126 The output is either "Verified OK" or "Verification Failure".
128 =item B<-prverify> I<filename>
130 Verify the signature using the private key in "filename".
132 =item B<-signature> I<filename>
134 The actual signature to verify.
136 =item B<-hmac> I<key>
138 Create a hashed MAC using "key".
140 The L<openssl-mac(1)> command should be preferred to using this command line
145 Create MAC (keyed Message Authentication Code). The most popular MAC
146 algorithm is HMAC (hash-based MAC), but there are other MAC algorithms
147 which are not based on hash, for instance B<gost-mac> algorithm,
148 supported by the B<gost> engine. MAC keys and other options should be set
149 via B<-macopt> parameter.
151 The L<openssl-mac(1)> command should be preferred to using this command line
154 =item B<-macopt> I<nm>:I<v>
156 Passes options to MAC algorithm, specified by B<-mac> key.
157 Following options are supported by both by B<HMAC> and B<gost-mac>:
161 =item B<key>:I<string>
163 Specifies MAC key as alphanumeric string (use if key contain printable
164 characters only). String length must conform to any restrictions of
165 the MAC algorithm for example exactly 32 chars for gost-mac.
167 =item B<hexkey>:I<string>
169 Specifies MAC key in hexadecimal form (two hex digits per byte).
170 Key length must conform to any restrictions of the MAC algorithm
171 for example exactly 32 chars for gost-mac.
175 The L<openssl-mac(1)> command should be preferred to using this command line
178 =item B<-fips-fingerprint>
180 Compute HMAC using a specific key for certain OpenSSL-FIPS operations.
182 {- $OpenSSL::safe::opt_r_item -}
184 {- $OpenSSL::safe::opt_engine_item -}
185 {- output_off() if $disabled{"deprecated-3.0"}; "" -}
186 The engine is not used for digests unless the B<-engine_impl> option is
187 used or it is configured to do so, see L<config(5)/Engine Configuration Module>.
189 =item B<-engine_impl> I<id>
191 When used with the B<-engine> option, it specifies to also use
192 engine I<id> for digest operations.
194 {- output_on() if $disabled{"deprecated-3.0"}; "" -}
195 {- $OpenSSL::safe::opt_provider_item -}
199 File or files to digest. If no files are specified then standard input is
207 To create a hex-encoded message digest of a file:
209 openssl dgst -md5 -hex file.txt
213 To sign a file using SHA-256 with binary file output:
215 openssl dgst -sha256 -sign privatekey.pem -out signature.sign file.txt
217 openssl sha256 -sign privatekey.pem -out signature.sign file.txt
219 To verify a signature:
221 openssl dgst -sha256 -verify publickey.pem \
222 -signature signature.sign \
228 The digest mechanisms that are available will depend on the options
229 used when building OpenSSL.
230 The C<openssl list -digest-algorithms> command can be used to list them.
232 New or agile applications should use probably use SHA-256. Other digests,
233 particularly SHA-1 and MD5, are still widely used for interoperating
234 with existing formats and protocols.
236 When signing a file, this command will automatically determine the algorithm
237 (RSA, ECC, etc) to use for signing based on the private key's ASN.1 info.
238 When verifying signatures, it only handles the RSA, DSA, or ECDSA signature
239 itself, not the related data to identify the signer and algorithm used in
240 formats such as x.509, CMS, and S/MIME.
242 A source of random numbers is required for certain signing algorithms, in
243 particular ECDSA and DSA.
245 The signing and verify options should only be used if a single file is
246 being signed or verified.
248 Hex signatures cannot be verified using B<openssl>. Instead, use "xxd -r"
249 or similar program to transform the hex signature into a binary signature
250 prior to verification.
252 The L<openssl-mac(1)> command is preferred over the B<-hmac>, B<-mac> and
253 B<-macopt> command line options.
261 The default digest was changed from MD5 to SHA256 in OpenSSL 1.1.0.
262 The FIPS-related options were removed in OpenSSL 1.1.0.
264 The B<-engine> and B<-engine_impl> options were deprecated in OpenSSL 3.0.
268 Copyright 2000-2022 The OpenSSL Project Authors. All Rights Reserved.
270 Licensed under the Apache License 2.0 (the "License"). You may not use
271 this file except in compliance with the License. You can obtain a copy
272 in the file LICENSE in the source distribution or at
273 L<https://www.openssl.org/source/license.html>.