Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mdeh

macrumors 6502
Original poster
Jan 3, 2009
345
2
I am trying to implement sha256 in a class in Objective C. In the process, I want to check the accuracy of what I am doing, by doing, what I **thought** was something simple....checking the value against the same operation in "terminal".

But, I am stumped.

The man pages for sha256 show this.

COMMANDS
::sha2::sha256 ?-hex|-bin? [ -channel channel | -file filename | string

and give an example thus.

% sha2::sha256 "Tcl does SHA256"
0b91043ee484abd83c3e4b08d6034d71b937026379f0f59bda6e625e6e214789

error I am getting is:
sha2::sha256 "Tcl does SHA256"
-bash: sha2::sha256: command not found

I have tried every which way to Sunday ( including just about every variation of the above ) , but I cannot get this to work, and there is very little in "googlesphere" about this, so it's time to ask those that do know. :)

Needless to say, my experience in terminal is somewhat limited, so any help would be greatly appreciated.
 
echo "Tcl does SHA256" | shasum -a 256
519038e722b94fb61a59ad632ae8ab55809c203fa2f2762fd573d6355d3df0d6 -

I got a different result than your example, though... so you may want to investigate further.

-Lee
 
echo "Tcl does SHA256" | shasum -a 256
519038e722b94fb61a59ad632ae8ab55809c203fa2f2762fd573d6355d3df0d6 -

I got a different result than your example, though... so you may want to investigate further.

-Lee

echo pops a '\n' onto the end of the string. Using 'echo -n' fixes it.
 
I'm not on a Mac currently, but googling shows that you might be trying to use a Tcl package. I don't know much about how to use Tcl (or at least not on a Mac), but I don't think you can run it from the Terminal directly. There might be an interactive Tcl environment that you can run that command in.

Basically, the "command" you're trying is not a Bash shell executable. So you get that error. It looks like a Tcl function call and you need to find a way to execute that Tcl function call. So you might research how to use Tcl on the Mac. There might be other tools to calculate that hash that don't use Tcl too, but my googling doesn't find any obvious ones (e.g. cksum on Mac doesn't calculate it).

EDIT:
Apparently lee has pointed out the "shasum" tool.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.