do shell script Result Differs from Terminal Result
I'm attempting to write an AppleScript that needs to generate a SHA256 hash from a Variable.
Using do shell script, OpenSSL is given a string to hash. However the result given from AppleScript is different to the result given from Terminal.
AppleScript:
set myString to do shell script ("echo -n stringtohash | /usr/local/bin/openssl sha256 2>&1")
display dialog (myString)
Terminal:
Computer:~ Matt$ echo -n stringtohash | /usr/local/bin/openssl sha256 2>&1
(stdin)= bc287cfa8c0c84f0b1489bc70ec1bdf75e593c13dc8b8a19bc2d0039966d69d1
MacBook Pro (Retina, 15-inch, Late 2013), macOS Sierra (10.12.5)