checking sha256 in terminal problem

Discussion in 'Mac Programming' started by mdeh, Mar 26, 2010.

  1. mdeh macrumors 6502

    Joined:
    Jan 3, 2009
    #1
    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.

    and give an example thus.

    error I am getting is:
    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.
     
  2. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #2
    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
     
  3. Guiyon macrumors 6502a

    Joined:
    Mar 19, 2008
    Location:
    North Shore, MA
    #3
    echo pops a '\n' onto the end of the string. Using 'echo -n' fixes it.
     
  4. jpyc7 macrumors 6502

    Joined:
    Mar 8, 2009
    Location:
    Denver, CO
    #4
    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.
     
  5. mdeh thread starter macrumors 6502

    Joined:
    Jan 3, 2009
    #5

    A huge thank you to everyone. The -n switch makes a big difference, so thanks for that too.
     

Share This Page