User Tools

Site Tools


ubuntu:openssl:compute_a_checksum_of_a_file

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
ubuntu:openssl:compute_a_checksum_of_a_file [2021/01/29 14:32] – created peterubuntu:openssl:compute_a_checksum_of_a_file [2021/01/29 15:53] (current) – [Compute an MD5 Checksum for all files in a directory] peter
Line 1: Line 1:
 ====== Ubuntu - OpenSSL - Compute a checksum of a file ====== ====== Ubuntu - OpenSSL - Compute a checksum of a file ======
 +
 +OpenSSL can compute a checksum (digest) against a file.
 +
 +To ensure that the contents of a file has not been tampered with, OpenSSL can compute a unique checksum for the file.
 +
 +Once this checksum is computed, it can be shared and, for example, anyone downloading the file can run the same checksum process to ensure that they get the same checksum - which ensures that the contents of a file have not changed.
 +
 +----
 +
 +===== Get a list of checksum methods that OpenSSL supports =====
 +
 +<code bash>
 +openssl dgst -list
 +</code>
 +
 +returns:
 +
 +<code bash>
 +Supported digests:
 +-blake2b512                -blake2s256                -md4                      
 +-md5                       -md5-sha1                  -ripemd                   
 +-ripemd160                 -rmd160                    -sha1                     
 +-sha224                    -sha256                    -sha3-224                 
 +-sha3-256                  -sha3-384                  -sha3-512                 
 +-sha384                    -sha512                    -sha512-224               
 +-sha512-256                -shake128                  -shake256                 
 +-sm3                       -ssl3-md5                  -ssl3-sha1                
 +-whirlpool                 
 +
 +</code>
 +
 +----
 +
 +===== Compute an MD5 Checksum for a file =====
 +
 +<code bash>
 +openssl dgst -md5 test.sh
 +</code>
 +
 +returns:
 +
 +<code bash>
 +MD5(test.sh)= 68e2009b8a69745f4371011194a16116
 +</code>
 +
 +<WRAP info>
 +**NOTE:**  This can also be run as:
 +
 +<code bash>
 +openssl md5 test.sh
 +</code>
 +
 +</WRAP>
 +
 +----
 +
 +===== Compute an MD5 Checksum for all files in a directory =====
 +
 +OpenSSL can also be combined with find to produce fingerprints for several files:
 +
 +<code bash>
 +find /home/peter -type f -print0 | xargs -0 openssl md5
 +
 +or
 +
 +find /home/peter -type f| xargs -d '\n' openssl md5
 +</code>
 +
 +<WRAP info>
 +**NOTE:**  The xargs command takes white space characters (tabs, spaces, new lines) as delimiters.
 +
 +To accommodate for files which may contain spaces, the **-d** option is used to limit xarg delimiters to only the new line characters ('\n').
 +</WRAP>
  
ubuntu/openssl/compute_a_checksum_of_a_file.1611930735.txt.gz · Last modified: 2021/01/29 14:32 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki