0

I tried with openssl as it is very fast:

openssl sha1 "$(basename "very_big_image.png")"

But this just substitutes the actual file for check summing.

mustaqim
  • 3
  • 1
  • Why are you using basename? Will you want to pass a path? If you already have the name of the file, why add `basename`? – terdon Apr 17 '20 at 13:43

1 Answers1

3

If you mean the checksum of the string used as a file name, you need to pass the string to your preferred checksum tool:

$ printf 'very_big_image.png' | openssl sha1
(stdin)= a2f2cfa4c7042222ecd8d980e7b26e46ee0895e5
$ printf 'very_big_image.png' | md5sum
52846a1d6726e254756f47cfaf9e116a  -
$ printf 'very_big_image.png' | sha512sum 
6133cf578b5c9aa515e3670712641e17cb55c3d9f1403a07718bdcb0dd02f3f5711bf87f54e2cbee3890d842ff0acd7ac5e62cdc0cd4f1e3a1d92486c5c3fbe8  -

If you want the contents of the file, then pass the file name:

$ md5sum very_big_image.png 
d3b07384d113edec49eaa6238ad5ff00  very_big_image.png
$ sha512sum very_big_image.png 
0cf9180a764aba863a67b6d72f0918bc131c6772642cb2dce5a34f0a702f9470ddc2bf125c12198b1995c233c34b4afd346c54a2334c350a948a51b6e8b4e6b6  very_big_image.png

Some commonly available hashing tools are:

md5sum
sha224sum 
sha256sum 
sha384sum 
sha512sum
terdon
  • 234,489
  • 66
  • 447
  • 667
  • @steeldriver oh, duh! Thanks, for some reason I thought the OP was also asking for basic tools for it. I should have mentioned openssl since it's in the OP! – terdon Apr 17 '20 at 15:00