1

Does anyone knows how the dgst function of the Openssl library manage the input value? I mean, it considers the input value as ASCII characters or in any other charset encoding?
I'm trying to input hexadecimal values but can't find how to do this:

$echo -n "FFFF" | openssl dgst -sha256

The result is different from the obtained by other ways (e.g. Java's MessageDigest) with the hexadecimal number '0xFFFF' as input.

1

1 Answer 1

0

Normally dgst takes ASCII input, to get hash of 0xFFFF try:

printf "\xFF\xFF" | openssl dgst -sha256

The result should be: ca2fd00fa001190744c15c317643ab092e7048ce086a243e2be9437c898de1bb

Sign up to request clarification or add additional context in comments.

2 Comments

That's correct. Now I must figure out how to convert large hex numbers into that format.
For example using one of the many answers from here: stackoverflow.com/questions/1604765/… . You'll probably want to write a bash script to even further simplify your sha256 digest usage.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.