Feature request: Working in "Binary/Hex" mode
mundodisco8 opened this issue · comments
Is your feature request related to a problem? Please describe.
I'm trying to get the hash of a message, but I would like my input to be a binary/hex representation of the message. In my application, I get a string with numbers, and put it in an input buffer of 16B (leaving zeroes on those positions that are left unused)
For example, for the ASCII message:
123456
whose binary / hex representation is
0x31 0x32 0x33 0x34 0x35 0x36
The input array becomes
0x31 0x32 0x33 0x34 0x35 0x36 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
and if we remove the 0x
,
31323334353600000000000000000000
When I ask CyberChef to hash it with SHA-256, I get the following output:
9866b0a349446d2fd54faa22ad0c8078090a1f86054737cf9055a9b4c070943e
While I expect:
d115a354d46efe76a2b3a79e0bebae207c1fe9c6709a8cfddfa7c45abb8c0913
Describe the solution you'd like
I would like to define somehow that my input for the next block is hexadecimal, and doesn't need to be parsed as one character - one byte, but as two characters - one byte.
Describe alternatives you've considered
I haven't managed to find a way to work in hex mode.
Additional context
Here's a link to a recipe that shows what I call the unexpected behaviour
This SHA-256 calculator allows to switch the input from text
and hex
. If you try the input
31323334353600000000000000000000
And choose hex
mode in the input type dropdown, you get what I expect (parse the input as a 16B hex number)
d115a354d46efe76a2b3a79e0bebae207c1fe9c6709a8cfddfa7c45abb8c0913
And if you choose text
, you parse the input as a 32B ASCII string and you get the same output that CyberChef does
9866b0a349446d2fd54faa22ad0c8078090a1f86054737cf9055a9b4c070943e
Answering my own question and closing
The solution is to use From Hexdump
as a way to input binary data. For example, to calculate the SHA of a 16B array cleared with zeroes, containing 123456
(ASCII, 0x313233343536
in hex), you can use this operation