openssl-dgst
perform message digest operations
TLDR
Calculate SHA256 hash of a file
$ openssl dgst -sha256 [file]
Calculate MD5 hash$ openssl dgst -md5 [file]
Output hash in coreutils-compatible format$ openssl dgst -sha256 -r [file]
Calculate hash and write output to a file$ openssl dgst -sha256 -out [hash.txt] [file]
Create an HMAC using a key$ openssl dgst -sha256 -hmac "[secret_key]" [file]
Sign a file with a private key$ openssl dgst -sha256 -sign [private.pem] -out [signature.bin] [file]
Verify a signature with a public key$ openssl dgst -sha256 -verify [public.pem] -signature [signature.bin] [file]
SYNOPSIS
openssl dgst [options] [file...]
DESCRIPTION
openssl dgst outputs the message digest of files in hexadecimal form. It supports various algorithms including SHA-256, SHA-512, SHA-384, SHA-1, and MD5. Can also generate and verify digital signatures using asymmetric keys, and create HMACs. If no files are specified, standard input is used.
PARAMETERS
-sha256, -sha512, -sha384, -sha1, -md5
Hash algorithm to use. Default is sha256.-sign keyfile
Sign the digest using the private key in the specified file.-verify keyfile
Verify the signature using the public key in the specified file.-prverify keyfile
Verify the signature using the private key in the specified file.-signature file
The signature file to verify against.-hmac key
Create a hashed MAC using the given key.-out filename
Output filename. Default is standard output.-r
Output hash in coreutils-compatible format.-hex
Output as hex dump (default).-binary
Output the digest in binary form.-c
Print the digest in two-digit groups separated by colons.-keyform arg
Key format: PEM, DER, P12, or ENGINE.-passin arg
Private key password source.-sigopt nm:v
Pass options to the signature algorithm during sign or verify.-list
Print a list of supported digest algorithms.
SEE ALSO
openssl(1), sha256sum(1), openssl-genrsa(1), openssl-rsa(1)
