I have a 32 byte key stored in a file called test_key.key
I wish to use openssl to create hash of a different file called mytext.txt. I need to create the hash using HMAC-SHA-256 & the key in test_key.key
I thought I had it working with the following command:
openssl dgst -sha256 -hmac $test_key.key mytext.txt
However, on closer examination I noticed it was using the string "test_key.key", not the actual file contents. I have tried a few different variations of this for the key file such as:
"$test_key.key"
'$test_key.key'
/test_key.key
Sadly, they all seem to have the same problem.
Can anyone advise me on this? I wish to keep this as a one line command if possible.
openssl dgst -sha256 -hmac $(<test_key.key) mytext.txtopenssl dgst -sha256 -mac HMAC -macopt "hexkey:$(xxd -ps -c32 test_key.key)" mytext.txtthat is explicit about the key format.unsigned charyou should be fine (as long as there isn't a'/* 'or something else that could be interpreted as a independent command) I wouldn't recommend it for much else.openssl ... $(<test_key.key) ...exposes the key in the process info