Reputation: 901
How do we input value and key as hexadecimal values?
echo -n "value" | openssl dgst -sha1 -hmac "key"
$value=11111111FFAA2211
$key=11111111FFAA2211000000000011BBFF
echo -n "$value" | openssl dgst -sha1 -hmac "$key"
is not working either.
Upvotes: 3
Views: 4494
Reputation: 901
I just managed to solved it, it's the use of the '-macopt hexkey:string' option.
echo -n '4869205468657265' | xxd -r -p | openssl dgst -sha512 -mac HMAC -macopt hexkey:0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b
(stdin)= 87aa7cdea5ef619d4ff0b4241a1d6cb02379f4e2ce4ec2787ad0b30545e17cdedaa833b7d6b8a702038b274eaea3f4e4be9d914eeb61f1702e696c203a126854
or
key='0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b'
value='4869205468657265'
echo -n "$value" | xxd -r -p | openssl dgst -sha512 -mac HMAC -macopt hexkey:$key
(stdin)= 87aa7cdea5ef619d4ff0b4241a1d6cb02379f4e2ce4ec2787ad0b30545e17cdedaa833b7d6b8a702038b274eaea3f4e4be9d914eeb61f1702e696c203a126854
I hope this answer may serve as a mini tutorial to help people.
Upvotes: 4