{
    "content": [
        {
            "type": "text",
            "text": "# openssl-dgst (man)\n\n## NAME\n\nopenssl-dgst - perform digest operations\n\n## SYNOPSIS\n\nopenssl dgst|digest [-digest] [-list] [-help] [-c] [-d] [-debug] [-hex] [-binary] [-xoflen\nlength] [-r] [-out filename] [-sign filename|uri] [-keyform DER|PEM|P12|ENGINE] [-passin arg]\n[-verify filename] [-prverify filename] [-signature filename] [-sigopt nm:v] [-hmac key]\n[-mac alg] [-macopt nm:v] [-fips-fingerprint] [-engine id] [-engineimpl id] [-rand files]\n[-writerand file] [-provider name] [-provider-path path] [-propquery propq] [file ...]\n\n## DESCRIPTION\n\nThis command output the message digest of a supplied file or files in hexadecimal, and also\ngenerates and verifies digital signatures using message digests.\n\n## TLDR\n\n> Generate digest values and perform signature operations.\n\n- Calculate the SHA256 digest for a file, saving the result to a specific file:\n  `openssl dgst -sha256 -binary -out {{output_file}} {{input_file}}`\n- Sign a file using an RSA key, saving the result to a specific file:\n  `openssl dgst -sign {{private_key_file}} -sha256 -sigopt rsa_padding_mode:pss -out {{output_file}} {{input_file}}`\n- Verify an RSA signature:\n  `openssl dgst -verify {{public_key_file}} -signature {{signature_file}} -sigopt rsa_padding_mode:pss {{signature_message_file}}`\n- Sign a file using and ECDSA key:\n  `openssl dgst -sign {{private_key_file}} -sha256 -out {{output_file}} {{input_file}}`\n- Verify an ECDSA signature:\n  `openssl dgst -verify {{public_key_file}} -signature {{signature_file}} {{signature_message_file}}`\n\n*Source: tldr-pages*\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **OPTIONS** (27 subsections)\n- **EXAMPLES**\n- **NOTES**\n- **SEE ALSO**\n- **HISTORY**\n- **COPYRIGHT**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "openssl-dgst",
        "section": "",
        "mode": "man",
        "summary": "openssl-dgst - perform digest operations",
        "synopsis": "openssl dgst|digest [-digest] [-list] [-help] [-c] [-d] [-debug] [-hex] [-binary] [-xoflen\nlength] [-r] [-out filename] [-sign filename|uri] [-keyform DER|PEM|P12|ENGINE] [-passin arg]\n[-verify filename] [-prverify filename] [-signature filename] [-sigopt nm:v] [-hmac key]\n[-mac alg] [-macopt nm:v] [-fips-fingerprint] [-engine id] [-engineimpl id] [-rand files]\n[-writerand file] [-provider name] [-provider-path path] [-propquery propq] [file ...]",
        "tldr_summary": "Generate digest values and perform signature operations.",
        "tldr_examples": [
            {
                "description": "Calculate the SHA256 digest for a file, saving the result to a specific file",
                "command": "openssl dgst -sha256 -binary -out {{output_file}} {{input_file}}"
            },
            {
                "description": "Sign a file using an RSA key, saving the result to a specific file",
                "command": "openssl dgst -sign {{private_key_file}} -sha256 -sigopt rsa_padding_mode:pss -out {{output_file}} {{input_file}}"
            },
            {
                "description": "Verify an RSA signature",
                "command": "openssl dgst -verify {{public_key_file}} -signature {{signature_file}} -sigopt rsa_padding_mode:pss {{signature_message_file}}"
            },
            {
                "description": "Sign a file using and ECDSA key",
                "command": "openssl dgst -sign {{private_key_file}} -sha256 -out {{output_file}} {{input_file}}"
            },
            {
                "description": "Verify an ECDSA signature",
                "command": "openssl dgst -verify {{public_key_file}} -signature {{signature_file}} {{signature_message_file}}"
            }
        ],
        "tldr_source": "official",
        "flags": [
            {
                "flag": "",
                "long": null,
                "arg": null,
                "description": "Print out a usage message."
            },
            {
                "flag": "",
                "long": null,
                "arg": null,
                "description": "Specifies name of a supported digest to be used. See option -list below :"
            },
            {
                "flag": "",
                "long": null,
                "arg": null,
                "description": "Prints out a list of supported message digests."
            },
            {
                "flag": "-c",
                "long": null,
                "arg": null,
                "description": "option is given as well."
            },
            {
                "flag": "-d",
                "long": null,
                "arg": null,
                "description": "Print out BIO debugging information."
            },
            {
                "flag": "",
                "long": null,
                "arg": null,
                "description": "Digest is to be 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."
            },
            {
                "flag": "",
                "long": null,
                "arg": null,
                "description": "Output the digest or signature in binary form."
            },
            {
                "flag": "",
                "long": null,
                "arg": null,
                "description": "Set the output length for XOF algorithms, such as shake128 and shake256. This option is not supported for signing operations. For OpenSSL providers it is recommended to set this value for shake algorithms, since the default values are set to only supply half of the maximum security strength. For backwards compatibility reasons the default xoflen length for shake128 is 16 (bytes) which results in a security strength of only 64 bits. To ensure the maximum security strength of 128 bits, the xoflen should be set to at least 32. For backwards compatibility reasons the default xoflen length for shake256 is 32 (bytes) which results in a security strength of only 128 bits. To ensure the maximum security strength of 256 bits, the xoflen should be set to at least 64."
            },
            {
                "flag": "-r",
                "long": null,
                "arg": null,
                "description": "sha1sum(1)."
            },
            {
                "flag": "",
                "long": null,
                "arg": null,
                "description": "Filename to output to, or standard output by default."
            },
            {
                "flag": "",
                "long": null,
                "arg": null,
                "description": "Digitally sign the digest using the given private key. Note this option does not support Ed25519 or Ed448 private keys. Use the openssl-pkeyutl(1) command instead for this."
            },
            {
                "flag": "",
                "long": null,
                "arg": null,
                "description": "The format of the key to sign with; unspecified by default. See openssl-format-options(1) for details."
            },
            {
                "flag": "",
                "long": null,
                "arg": null,
                "description": "Pass options to the signature algorithm during sign or verify operations. Names and values of these options are algorithm-specific."
            },
            {
                "flag": "",
                "long": null,
                "arg": null,
                "description": "The private key password source. For more information about the format of arg see openssl-passphrase-options(1)."
            },
            {
                "flag": "",
                "long": null,
                "arg": null,
                "description": "Verify the signature using the public key in \"filename\". The output is either \"Verified OK\" or \"Verification Failure\"."
            },
            {
                "flag": "",
                "long": null,
                "arg": null,
                "description": "Verify the signature using the private key in \"filename\"."
            },
            {
                "flag": "",
                "long": null,
                "arg": null,
                "description": "The actual signature to verify."
            },
            {
                "flag": "",
                "long": null,
                "arg": null,
                "description": "Create a hashed MAC using \"key\". The openssl-mac(1) command should be preferred to using this command line option."
            },
            {
                "flag": "",
                "long": null,
                "arg": null,
                "description": "Create MAC (keyed Message Authentication Code). The most popular MAC algorithm is HMAC (hash-based MAC), but there are other MAC algorithms which are not based on hash, for instance gost-mac algorithm, supported by the gost engine. MAC keys and other options should be set via -macopt parameter. The openssl-mac(1) command should be preferred to using this command line option."
            },
            {
                "flag": "",
                "long": null,
                "arg": null,
                "description": "Passes options to MAC algorithm, specified by -mac key. Following options are supported by both by HMAC and gost-mac: key:string Specifies MAC key as alphanumeric string (use if key contain printable characters only). String length must conform to any restrictions of the MAC algorithm for example exactly 32 chars for gost-mac. hexkey:string Specifies MAC key in hexadecimal form (two hex digits per byte). Key length must conform to any restrictions of the MAC algorithm for example exactly 32 chars for gost-mac. The openssl-mac(1) command should be preferred to using this command line option."
            },
            {
                "flag": "",
                "long": null,
                "arg": null,
                "description": "Compute HMAC using a specific key for certain OpenSSL-FIPS operations."
            },
            {
                "flag": "",
                "long": null,
                "arg": null,
                "description": "See \"Random State Options\" in openssl(1) for details."
            },
            {
                "flag": "",
                "long": null,
                "arg": null,
                "description": "See \"Engine Options\" in openssl(1). This option is deprecated. The engine is not used for digests unless the -engineimpl option is used or it is configured to do so, see \"Engine Configuration Module\" in config(5)."
            },
            {
                "flag": "",
                "long": null,
                "arg": null,
                "description": "When used with the -engine option, it specifies to also use engine id for digest operations."
            },
            {
                "flag": "",
                "long": null,
                "arg": null,
                "description": ""
            },
            {
                "flag": "",
                "long": null,
                "arg": null,
                "description": ""
            },
            {
                "flag": "",
                "long": null,
                "arg": null,
                "description": "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."
            }
        ],
        "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"
        ],
        "see_also": [
            {
                "name": "openssl-mac",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/openssl-mac/1/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 6,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 7,
                "subsections": []
            },
            {
                "name": "OPTIONS",
                "lines": 1,
                "subsections": [
                    {
                        "name": "-help",
                        "lines": 2
                    },
                    {
                        "name": "-\u001b[4mdigest",
                        "lines": 2
                    },
                    {
                        "name": "-list",
                        "lines": 2
                    },
                    {
                        "name": "-c   -hex",
                        "lines": 2,
                        "flag": "-c"
                    },
                    {
                        "name": "-d -debug",
                        "lines": 2,
                        "flag": "-d"
                    },
                    {
                        "name": "-hex",
                        "lines": 3
                    },
                    {
                        "name": "-binary",
                        "lines": 2
                    },
                    {
                        "name": "-xoflen _",
                        "lines": 14
                    },
                    {
                        "name": "-r",
                        "lines": 2,
                        "flag": "-r"
                    },
                    {
                        "name": "-out _",
                        "lines": 2
                    },
                    {
                        "name": "-sign _",
                        "lines": 3
                    },
                    {
                        "name": "-keyform DER",
                        "lines": 3
                    },
                    {
                        "name": "-sigopt _",
                        "lines": 3
                    },
                    {
                        "name": "-passin _",
                        "lines": 3
                    },
                    {
                        "name": "-verify _",
                        "lines": 3
                    },
                    {
                        "name": "-prverify _",
                        "lines": 2
                    },
                    {
                        "name": "-signature _",
                        "lines": 2
                    },
                    {
                        "name": "-hmac _",
                        "lines": 4
                    },
                    {
                        "name": "-mac _",
                        "lines": 7
                    },
                    {
                        "name": "-macopt _",
                        "lines": 15
                    },
                    {
                        "name": "-fips-fingerprint",
                        "lines": 2
                    },
                    {
                        "name": "-rand _ -writerand _",
                        "lines": 2
                    },
                    {
                        "name": "-engine _",
                        "lines": 5
                    },
                    {
                        "name": "-engine_impl _",
                        "lines": 3
                    },
                    {
                        "name": "-provider _",
                        "lines": 1
                    },
                    {
                        "name": "-provider-path _",
                        "lines": 1
                    },
                    {
                        "name": "-propquery _",
                        "lines": 5
                    }
                ]
            },
            {
                "name": "EXAMPLES",
                "lines": 18,
                "subsections": []
            },
            {
                "name": "NOTES",
                "lines": 23,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "HISTORY",
                "lines": 5,
                "subsections": []
            },
            {
                "name": "COPYRIGHT",
                "lines": 7,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "openssl-dgst - perform digest operations\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "openssl dgst|digest [-digest] [-list] [-help] [-c] [-d] [-debug] [-hex] [-binary] [-xoflen\nlength] [-r] [-out filename] [-sign filename|uri] [-keyform DER|PEM|P12|ENGINE] [-passin arg]\n[-verify filename] [-prverify filename] [-signature filename] [-sigopt nm:v] [-hmac key]\n[-mac alg] [-macopt nm:v] [-fips-fingerprint] [-engine id] [-engineimpl id] [-rand files]\n[-writerand file] [-provider name] [-provider-path path] [-propquery propq] [file ...]\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "This command output the message digest of a supplied file or files in hexadecimal, and also\ngenerates and verifies digital signatures using message digests.\n\nThe generic name, openssl dgst, may be used with an option specifying the algorithm to be\nused.  The default digest is sha256.  A supported digest name may also be used as the sub-\ncommand name.  To see the list of supported algorithms, use \"openssl list -digest-algorithms\"\n",
                "subsections": []
            },
            "OPTIONS": {
                "content": "",
                "subsections": [
                    {
                        "name": "-help",
                        "content": "Print out a usage message.\n"
                    },
                    {
                        "name": "-\u001b[4mdigest",
                        "content": "Specifies name of a supported digest to be used. See option -list below :\n"
                    },
                    {
                        "name": "-list",
                        "content": "Prints out a list of supported message digests.\n"
                    },
                    {
                        "name": "-c   -hex",
                        "content": "option is given as well.\n",
                        "flag": "-c"
                    },
                    {
                        "name": "-d -debug",
                        "content": "Print out BIO debugging information.\n",
                        "flag": "-d"
                    },
                    {
                        "name": "-hex",
                        "content": "Digest is to be output as a hex dump. This is the default case for a \"normal\"  digest  as\nopposed to a digital signature.  See NOTES below for digital signatures using -hex.\n"
                    },
                    {
                        "name": "-binary",
                        "content": "Output the digest or signature in binary form.\n"
                    },
                    {
                        "name": "-xoflen _",
                        "content": "Set  the output length for XOF algorithms, such as shake128 and shake256.  This option is\nnot supported for signing operations.\n\nFor OpenSSL providers it is recommended to set this value for shake algorithms, since the\ndefault values are set to only supply half of the maximum security strength.\n\nFor backwards compatibility reasons the default xoflen length for shake128 is 16  (bytes)\nwhich  results  in  a  security  strength of only 64 bits. To ensure the maximum security\nstrength of 128 bits, the xoflen should be set to at least 32.\n\nFor backwards compatibility reasons the default xoflen length for shake256 is 32  (bytes)\nwhich  results  in  a  security strength of only 128 bits. To ensure the maximum security\nstrength of 256 bits, the xoflen should be set to at least 64.\n"
                    },
                    {
                        "name": "-r",
                        "content": "sha1sum(1).\n",
                        "flag": "-r"
                    },
                    {
                        "name": "-out _",
                        "content": "Filename to output to, or standard output by default.\n"
                    },
                    {
                        "name": "-sign _",
                        "content": "Digitally  sign the digest using the given private key. Note this option does not support\nEd25519 or Ed448 private keys. Use the openssl-pkeyutl(1) command instead for this.\n"
                    },
                    {
                        "name": "-keyform DER",
                        "content": "The   format   of   the   key   to   sign   with;   unspecified    by    default.     See\nopenssl-format-options(1) for details.\n"
                    },
                    {
                        "name": "-sigopt _",
                        "content": "Pass  options  to  the  signature  algorithm during sign or verify operations.  Names and\nvalues of these options are algorithm-specific.\n"
                    },
                    {
                        "name": "-passin _",
                        "content": "The private key password source. For  more  information  about  the  format  of  arg  see\nopenssl-passphrase-options(1).\n"
                    },
                    {
                        "name": "-verify _",
                        "content": "Verify  the signature using the public key in \"filename\".  The output is either \"Verified\nOK\" or \"Verification Failure\".\n"
                    },
                    {
                        "name": "-prverify _",
                        "content": "Verify the signature using the private key in \"filename\".\n"
                    },
                    {
                        "name": "-signature _",
                        "content": "The actual signature to verify.\n"
                    },
                    {
                        "name": "-hmac _",
                        "content": "Create a hashed MAC using \"key\".\n\nThe openssl-mac(1) command should be preferred to using this command line option.\n"
                    },
                    {
                        "name": "-mac _",
                        "content": "Create MAC (keyed Message Authentication Code). The most popular MAC  algorithm  is  HMAC\n(hash-based  MAC),  but  there  are other MAC algorithms which are not based on hash, for\ninstance gost-mac algorithm, supported by the gost engine. MAC  keys  and  other  options\nshould be set via -macopt parameter.\n\nThe openssl-mac(1) command should be preferred to using this command line option.\n"
                    },
                    {
                        "name": "-macopt _",
                        "content": "Passes  options to MAC algorithm, specified by -mac key.  Following options are supported\nby both by HMAC and gost-mac:\n\nkey:string\nSpecifies MAC key as alphanumeric string (use if  key  contain  printable  characters\nonly).  String  length  must  conform  to  any  restrictions of the MAC algorithm for\nexample exactly 32 chars for gost-mac.\n\nhexkey:string\nSpecifies MAC key in hexadecimal form (two hex digits per  byte).   Key  length  must\nconform  to  any  restrictions  of the MAC algorithm for example exactly 32 chars for\ngost-mac.\n\nThe openssl-mac(1) command should be preferred to using this command line option.\n"
                    },
                    {
                        "name": "-fips-fingerprint",
                        "content": "Compute HMAC using a specific key for certain OpenSSL-FIPS operations.\n"
                    },
                    {
                        "name": "-rand _ -writerand _",
                        "content": "See \"Random State Options\" in openssl(1) for details.\n"
                    },
                    {
                        "name": "-engine _",
                        "content": "See \"Engine Options\" in openssl(1).  This option is deprecated.\n\nThe engine is not used for digests unless the  -engineimpl  option  is  used  or  it  is\nconfigured to do so, see \"Engine Configuration Module\" in config(5).\n"
                    },
                    {
                        "name": "-engine_impl _",
                        "content": "When  used  with  the  -engine  option,  it  specifies  to  also use engine id for digest\noperations.\n"
                    },
                    {
                        "name": "-provider _",
                        "content": ""
                    },
                    {
                        "name": "-provider-path _",
                        "content": ""
                    },
                    {
                        "name": "-propquery _",
                        "content": "See \"Provider Options\" in openssl(1), provider(7), and property(7).\n\nfile ...\nFile or files to digest. If no files are specified then standard input is used.\n"
                    }
                ]
            },
            "EXAMPLES": {
                "content": "To create a hex-encoded message digest of a file:\n\nopenssl dgst -md5 -hex file.txt\nor\nopenssl md5 file.txt\n\nTo sign a file using SHA-256 with binary file output:\n\nopenssl dgst -sha256 -sign privatekey.pem -out signature.sign file.txt\nor\nopenssl sha256 -sign privatekey.pem -out signature.sign file.txt\n\nTo verify a signature:\n\nopenssl dgst -sha256 -verify publickey.pem \\\n-signature signature.sign \\\nfile.txt\n",
                "subsections": []
            },
            "NOTES": {
                "content": "The digest mechanisms that are available will  depend  on  the  options  used  when  building\nOpenSSL.  The \"openssl list -digest-algorithms\" command can be used to list them.\n\nNew  or agile applications should use probably use SHA-256. Other digests, particularly SHA-1\nand MD5, are still widely used for interoperating with existing formats and protocols.\n\nWhen signing a file, this command will automatically determine the algorithm (RSA, ECC,  etc)\nto use for signing based on the private key's ASN.1 info.  When verifying signatures, it only\nhandles  the RSA, DSA, or ECDSA signature itself, not the related data to identify the signer\nand algorithm used in formats such as x.509, CMS, and S/MIME.\n\nA source of random numbers is required for certain signing algorithms,  in  particular  ECDSA\nand DSA.\n\nThe  signing  and  verify  options  should  only  be used if a single file is being signed or\nverified.\n\nHex signatures cannot be verified using openssl.  Instead, use \"xxd -r\" or similar program to\ntransform the hex signature into a binary signature prior to verification.\n\nThe openssl-mac(1) command is preferred  over  the  -hmac,  -mac  and  -macopt  command  line\noptions.\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "openssl-mac(1)\n",
                "subsections": []
            },
            "HISTORY": {
                "content": "The default digest was changed from MD5 to SHA256 in OpenSSL 1.1.0.  The FIPS-related options\nwere removed in OpenSSL 1.1.0.\n\nThe -engine and -engineimpl options were deprecated in OpenSSL 3.0.\n",
                "subsections": []
            },
            "COPYRIGHT": {
                "content": "Copyright 2000-2022 The OpenSSL Project Authors. All Rights Reserved.\n\nLicensed  under  the Apache License 2.0 (the \"License\").  You may not use this file except in\ncompliance with the License.  You can obtain a  copy  in  the  file  LICENSE  in  the  source\ndistribution or at <https://www.openssl.org/source/license.html>.\n\n3.0.13                                       2026-07-29                           OPENSSL-DGST(1SSL)",
                "subsections": []
            }
        }
    }
}