openssl

Hi,
i don’t know, but i get no results from:

set the_file to choose file
set sha_ to "sha256"
set prsum to (do shell script "openssl " & sha_ & " '" & POSIX path of the_file & "'")
-->{}

why? the syntax should be correct.

quoted form?

Hello.

:slight_smile: It isn’t quoted form.

try :


set res to (do shell script "which openssl")

and then try giving that one sha256 as argument, my guess is that you are accessing a version on your disk, presumably the one residing in /usr/bin, that doesn’t take that as argument, then all the output is redirected to stderr, and you are getting nothing back through stdout.

which -a shows you all the versions you have, and you can basically just specify the path of the working version in your do shell script to make it work.

Hi
thanks, but i set always: ’
they aren’t so visible, i know.

Ops: MacUsr!
yup, i get “/usr/bin/openssl”, only 1 version. You say the version i have has no sha256 support ? :frowning:

Are you trying to do this?

set the_file to quoted form of (POSIX path of (choose file))
set prsum to (do shell script "shasum -a 256 " & the_file)

Hello.

Yes, I am saying maybe you should look for the openssl you can get at macports.org or somewhere else.

@ Adayzdone : I haven’t got shasum256 for some unknown reason :).

Do you have shasum ?

No, not that one either.

I guess I got the upgraded version of openssl with something I have downloaded, like postfix or something. :slight_smile:

Maybe ?

However, openssl and shasum are two different commands.

man shasum
man openssl

Hello!

Yes they are different, but performs the same task. ( I found it, never used it before.)

set the_file to choose file
set sha_ to "sha256"
set prsum to (do shell script "openssl dgst -" & sha_ & " " & quoted form of POSIX path of the_file)

It seems like they both return the same result:


set the_file to quoted form of (POSIX path of (choose file))

-- DJ Bazzie Wazzie
set sha_ to "sha256"
set prsum to (do shell script "openssl dgst -" & sha_ & " " & the_file)

-- adayzdone
set prsum2 to (do shell script "shasum -a 256 " & the_file)

display dialog "DJ: " & prsum & return & return & "adayzdone: " & prsum2 buttons {"OK"} default button "OK"

shasum is a perl script that makes use of the SHA perl module and openssl is a C written command line util that makes use of the openssl C-Library. They should output the same because its an algorithm and the output of an algorithm should be exactly the same no matter what programming language. This is a typical case of a programmers preference which one to use rather than one better than the other.

Note: I’m assuming that shasum is using the DIGEST::SHA module and not the DIGEST::SHA::PUREPERL module because the pureperl module is slower in performance because it’s written in Perl while the DIGEST::SHA module is written in C for performance reasons. The ‘see also’ section in the man page is not clear about that.