Search code examples
hashopenssldigest

Openssl digest with hexadecimal coded input


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.


Solution

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

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

    The result should be: ca2fd00fa001190744c15c317643ab092e7048ce086a243e2be9437c898de1bb