Situation
I'm on FreeBSD 11.2 without GUI. I'm brand new to BSD systems.
Suppose we have a SHA512SUM
file generated on FreeBSD with:
sha512 encrypt-file-aes256 decrypt-file-aes256 > SHA512SUM
It looks different from the Linux format, which from Linux can be generated using --tag
switch:
SHA512 (encrypt-file-aes256) = 9170caaa45303d2e5f04c21732500980f3b06fc361018f953127506b56d3f2f46c95efdc291e160dd80e39b5304f327d83fe72c625ab5f31660db9c99dbfd017
SHA512 (decrypt-file-aes256) = 893693eec618542b0b95051952f9258824fe7004c360f8e6056a51638592510a704e27b707b9176febca655b7df581c9a6e2220b6511e8426c1501f6b2dd48a9
Question
How do I check this file? There is no --check
option in the man page.
Progress
So far, I am only able to manually test a single file with hard-coding the hash sum:
sha512 -c "9170caaa45303d2e5f04c21732500980f3b06fc361018f953127506b56d3f2f46c95efdc291e160dd80e39b5304f327d83fe72c625ab5f31660db9c99dbfd017" encrypt-file-aes256 && echo $?
Scripting-wise, I don't yet see a way of checking the whole SHA512SUM
file automatically.
Note, that it may contain many more files than the two as in my case.
Best Answer
You can use the
shasum
(man page) tool, which has a-c
option to check against a checksum file and is a front-end to several checksum algorithms including SHA-512.You can use a command like the one below to check both files:
The
shasum
tool is only able to parse the output format compatible with the one produced bysha512sum
(the tool usually shipped in Linux distributions.)You can convert from a BSD style checksum file to a Linux style one with a simple
sed
command:(Though if you're generating the checksums yourself, then also using
shasum
to generate them is a good option, also compatible with the tools found on Linux.)The
shasum
tool is provided by the FreeBSD portp5-Digest-SHA
and can be installed withpkg
by running: