Velvet Star Monitor

Standout celebrity highlights with iconic style.

general

customize output of command "openssl dgst -hmac"

Writer Matthew Martinez

I want to compute the HMAC of file A.txt and put it into file A_hmac.txt. I use openss library, now I have:

openssl dgst -hmac "myHmacKey" -out A_hmac.txt A.txt

The output, inside A_hmac.txt, is:

HMAC-SHA256(A.txt)= 5aaee07459e341752...

How do I manage to have as output only:

5aaee07459e341752...

Thanks

0

1 Answer

Though, Not an OpenSSL solution, In Linux;

openssl dgst -hmac "myHmacKey" output.txt

outputs

HMAC-SHA256(output.txt)= 3bcf4e453c9b8008035e7f5e0ea84f092f795fc602bb3adccfde0f916dd565b2

The using the cut on the space char

openssl dgst -hmac "myHmacKey" output.txt | rev | cut -d' ' -f1 | rev > myHmacKey

Then cat myHmacKey outputs

3bcf4e453c9b8008035e7f5e0ea84f092f795fc602bb3adccfde0f916dd565b2

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy