Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to installing sha1sum in MAC OS?

Tags:

macos

sha1

Problem: To get the sha1sum value of a file in MAC OS i run the following command

sha1sum file_name 

The error I got is following

perl version 5.18.2 can't run /usr/bin/sha1sum.  Try the alternative(s):  /usr/bin/sha1sum5.16 (uses perl 5.16)  Run "man perl" for more information about multiple version support in Mac OS X. 

I tried to install textutils and coreutils, but both failed. Can anyone suggest me how I can resolve the issue ? Thanks in advance.

like image 538
J4cK Avatar asked Feb 13 '15 00:02

J4cK


People also ask

How do I find sha1sum on Mac?

Or you can type the command openssl sha1 followed by space and drag and drop the file to the Terminal. Wait a while and you should see SHA1(/the/full/path/to/your/file)= followed by the checksum.

How do I hash a file on a Mac?

You can easily check the MD5 Hash of any file on your Mac, all you need to do is launch the Terminal and type the 'md5' command and point it at the file you wish to check the md5 has for.

What is Linux sha1sum?

sha1sum is a computer program that calculates and verifies SHA-1 hashes. It is commonly used to verify the integrity of files. It (or a variant) is installed by default on most Linux distributions.


2 Answers

You can install it in Mac OS using homebrew with brew install md5sha1sum. Got the info from this link https://raamdev.com/2008/howto-install-md5sum-sha1sum-on-mac-os-x/

like image 153
Federico Hernández Avatar answered Sep 18 '22 00:09

Federico Hernández


MacOS has shasum preinstalled, which calculates sha1 sum by default:

$ shasum --help Usage: shasum [OPTION]... [FILE]... Print or check SHA checksums. With no FILE, or when FILE is -, read standard input.    -a, --algorithm   1 (default), 224, 256, 384, 512, 512224, 512256 [...] 

Usage example:

$ echo -n "test" | shasum a94a8fe5ccb19ba61c4c0873d391e987982fbbd3  - 

Also openssl sha1 does the job:

$ echo -n "test" | openssl sha1 a94a8fe5ccb19ba61c4c0873d391e987982fbbd3 
like image 27
DarthVanger Avatar answered Sep 19 '22 00:09

DarthVanger