Let us consider a simple string in Hex:
2E
Its SHA value is:cdb4ee2aea69cc6a83331bbe96dc2caa9a299d21329efb0336fc02a82e1839a8
Yes, that's correct.
When converted into byte form should we write 46 or 046.
Neither.
The whole idea of using hexadecimals for bytes is to represent the value of the bytes. So 2E
is the hexadecimal representation of a single byte. You can also use other representations such as 00101110
in binary.
If you interpret it as ASCII text it would be the "dot" character. So printf "\x2E" | sha256sum
is the same as printf "." | sha256sum
on most systems. So on your site you could simply use a single dot as text. It's also possible to do this using echo
but echo
has too many portability issues to be considered a reliable alternative to printf
.
Generally we don't represent bytes using decimals. If you do you'll probably have to program it specifically. For instance in Java you could use byte b = 46
or byte[] ba = { 46 }
and then use that in a hash algorithm. If you really want to program it using command line then printf "\\x$(printf "%x" 46)" | sha256sum
seems to work.