I am follow a tutorial guide from this link http://osxdaily.com/2012/01/30/encrypt-and-decrypt-files-with-openssl/

to try to produce -sha256 hash from an input file but when i type openssl dgst -sha256 -in filename.txt

the command will return unknown option '-in'.

Can anyone please point out what have i gone wrong ?

OS Version: 10.11 OpenSSL Version: 1.0.2.d

  • Since Apple is changing systems - could you edit in what version of OS X you have and also what which openssl and openssl version report when you run them from the command line?
    – bmike
    Commented Oct 11, 2015 at 0:03

2 Answers 2


I don't get any errors when I make a temporary file:

openssl version > /$TMPDIR/foo
openssl dgst -sha256 /$TMPDIR/foo

My version is OpenSSL 0.9.8zg 14 July 2015 and the sha256 of the resulting foo file is

SHA256(/tmp/foo)= 34ff579703733495dc5b883f288b71653653c8b449da860a1b6fb382fde1a5f1

Maybe you just need to remove the -in to calculate your digest?

  • Appreciate for your respond bmike. Here is another 2 question hope you can answer that. Q1: Do you know how to output the SHA256 hash value to a text file that you have produce above to text file? cause -out apparently is not working in my case. Q2: If I just copy and paste the SHA256 hash to a text file manually, will that be any different if I just using the step from Q1 ?
    – Who
    Commented Oct 11, 2015 at 0:29
  • @who openssl dgst -sha256 foo > filename_digest.txt will work better than copy paste IMO.
    – bmike
    Commented Oct 11, 2015 at 13:52

This can happen if the command you're copying and pasting is written with a character other than a "common" hyphen. There are all manor of horizontal bars, en dashes, em dashes, etc. that look the similar and often make their way into published guides. Eg. these are all different characters: -, ־, , , , , , , , , , , etc.

Try typing the command manually.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .