ubuntu:openssl:compute_a_checksum_of_a_file
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
ubuntu:openssl:compute_a_checksum_of_a_file [2021/01/29 14:32] – created peter | ubuntu: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 | ||
+ | </ | ||
+ | |||
+ | returns: | ||
+ | |||
+ | <code bash> | ||
+ | Supported digests: | ||
+ | -blake2b512 | ||
+ | -md5 | ||
+ | -ripemd160 | ||
+ | -sha224 | ||
+ | -sha3-256 | ||
+ | -sha384 | ||
+ | -sha512-256 | ||
+ | -sm3 | ||
+ | -whirlpool | ||
+ | |||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Compute an MD5 Checksum for a file ===== | ||
+ | |||
+ | <code bash> | ||
+ | openssl dgst -md5 test.sh | ||
+ | </ | ||
+ | |||
+ | returns: | ||
+ | |||
+ | <code bash> | ||
+ | MD5(test.sh)= 68e2009b8a69745f4371011194a16116 | ||
+ | </ | ||
+ | |||
+ | <WRAP info> | ||
+ | **NOTE: | ||
+ | |||
+ | <code bash> | ||
+ | openssl md5 test.sh | ||
+ | </ | ||
+ | |||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== 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 ' | ||
+ | </ | ||
+ | |||
+ | <WRAP info> | ||
+ | **NOTE: | ||
+ | |||
+ | To accommodate for files which may contain spaces, the **-d** option is used to limit xarg delimiters to only the new line characters (' | ||
+ | </ | ||
ubuntu/openssl/compute_a_checksum_of_a_file.1611930735.txt.gz · Last modified: 2021/01/29 14:32 by peter