Go to main content

Managing Encryption and Certificates in Oracle® Solaris 11.3

Exit Print View

Updated: December 2018
 
 

How to Compute a Digest of a File

When you compute a digest of a file, you can check to see that the file has not been tampered with by comparing digest outputs. A digest does not alter the original file.

  1. List the available digest algorithms.
    $ digest -l
    sha1
    md5
    sha224
    sha256
    sha384
    sha512

    Note -  Whenever possible, select a FIPS 140-2 approved algorithm. See FIPS 140-2 Algorithms in the Cryptographic Framework in Using a FIPS 140-2 Enabled System in Oracle Solaris 11.3.
  2. Compute the digest of the file and save the digest listing.

    Provide an algorithm with the digest command.

    $ digest -v -a algorithm input-file > digest-listing
    –v

    Displays the output in the following format:

    algorithm (input-file) = digest
    –a algorithm

    The algorithm to use to compute a digest of the file. Type the algorithm as the algorithm appears in the output of Step 1.


    Note -  Whenever possible, select a FIPS 140-2 approved algorithm. See FIPS 140-2 Algorithms in the Cryptographic Framework in Using a FIPS 140-2 Enabled System in Oracle Solaris 11.3.
    input-file

    The input file for the digest command.

    digest-listing

    The output file for the digest command.

Example 6  Computing a Digest With the SHA1 Mechanism

In the following example, the digest command uses the SHA1 mechanism to provide a directory listing. The results are placed in a file.

$ digest -v -a sha512 docs/* > $HOME/digest.docs.legal.05.07
$ more ~/digest.docs.legal.05.07
sha512 (docs/legal1) = a269d...c618e1bf19b3d5c9f835242708eb2b572d7b
sha512 (docs/legal2) = 57be3...59a7168564296c142715cc9ed979dd838a7b
sha512 (docs/legal3) = ed31d...0fb3b80d4cd58327bcc29b2e7b90a0af6770
sha512 (docs/legal4) = 67ce1...0ba0c55695614329110d0686bc2773630b5f