Why do I get different results from Mac's shasum than from other shasum calculators?
Solution 1:
The input to the shasum
invocation in the question is test\n
(with a newline), not test
.
If you give test
with no newline to shasum
you’ll get the same output as the online tools cited:
$ echo -n "test" | shasum -a 512
ee26b0dd4af7e749aa1a8ee3c10ae9923f618980772e473f8819a5d4940e0db27ac185f8a0e1d5f84f88bc887fd67b143732c304cc5fa9ad8e6f57f50028a8ff -
By the way, I think there’s nothing MacOS-specific about the shasum
found on MacOS; I think shasum
is part of the standard Perl distro — installed along with, e.g., the perl
command.
Solution 2:
Try this:
hexdump -C <<< test
Knowing Unix shells, you're probably getting an unwanted 0x0a at the end of that string.