Get the Checksum of a File in Console/Terminal

MD5

MD5 is o.k. to check if the download of a file was complete, but it is not suitable to verify data integrity.

Change in the directory of the file to check:
      cd DIRECTORY_OF_THE_FILE

Type...
  • Linux:
        md5sum FILE_TO_CHECK

  • Windows:
        certUtil -hashfile FILE_TO_CHECK MD5

  • Mac:
        md5 FILE_TO_CHECK

  • BSD and other Unix systems:
        cksum -a sha256 FILE_TO_CHECK
    or
        md5 FILE_TO_CHECK

  • AIX:
        csum -h MD5 FILE_TO_CHECK

  • OpenSolaris:
         digest -a md5 FILE_TO_CHECK

  • HP-UX:
         md5sum FILE_TO_CHECK

If OpenSSL is installed you can always type:
      openssl md5 FILE_TO_CHECK



Get the SHA-256 checksum of a file

Change in the directory of the file to check:
      cd DIRECTORY_OF_THE_FILE

Type...
  • Linux:
        sha256sum FILE_TO_CHECK

  • Windows:
        certUtil -hashfile FILE_TO_CHECK SHA256

  • Mac:
        shasum -a 256 FILE_TO_CHECK

  • BSD and other Unix systems:
        cksum -a sha256 FILE_TO_CHECK
    or
        sha256 FILE_TO_CHECK

  • OpenSolaris:
        digest -a sha256 FILE_TO_CHECK

If OpenSSL is installed you can also type:
      openssl dgst -sha256 FILE_TO_CHECK



SHA-3

SHA-3 (Secure Hash Algorithm 3) was released by NIST on August 5, 2015.

Although it is now possible to compute the SHA-3 hash on some platforms without extra installation, the situation remains more complicated because SHA-3 has several possible instances with respective output lengths.

For example, the Linux command sha3sum FILE_TO_CHECK computes 224 bits by default. If you need a different output length, you have to specify it. This makes it unlikely that SHA-3 will become widely used for checksums.



Blake2b

Blake2b is faster than SHA256 (sometimes even faster than MD5) and more secure than SHA-256, but it is still not much supported.

If at least openssl-1.1 is installed you can type:
openssl dgst -blake2b512 FILE_TO_CHECK

You can also use the binaries for Linux/Windows of b2sum, you can find them here:
BLAKE2 site