# Is it possible to convert the output of sha256 hash to binary or decimal value? [closed]

Can the output value of the sha256 hash function be converted to binary or decimal number? I know that the output is a set of 256bits. Is it possible to convert the output data to an unique representation of zero and one?

## closed as off-topic by kelalaka, e-sushiDec 3 '18 at 9:11

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "Programming questions are off-topic even if you are writing or debugging cryptographic code. Unless your question is specifically about how the cryptographic algorithm, protocol or side-channel (mitigation) works, you should look into asking on Stack Overflow instead." – kelalaka, e-sushi
If this question can be reworded to fit the rules in the help center, please edit the question.

• This is a StackOverflow question. – kelalaka Nov 30 '18 at 13:51
• @kelalaka i though since it is about a hash function it is relative to cryptography. I am sorry i will ask the question to StackOverflow – kathi Nov 30 '18 at 14:09

## 1 Answer

Yes it's possible.

The output-type of a SHA256 (or many other hash algorithms) is raw binary.

So you can use this binary value to convert it to any format you want, i.e. decimal.

Example:

SHA256 hash of hello, world!

Binary: 110100011100110010101101011001001010001111001100111111010000011010110001011111011111000010010000011101010110000110101010001110001100110000110011111001111100111101000011010100111110000111001110101100000111000110101000001111111110011011010001111011100101000

Hex: 68e656b251e67e8358bef8483ab0d51c6619f3e7a1a9f0e75838d41ff368f728

Decimal: 47447509435240178963798524362534432113195114210189468302358324674552893339432

• This is untrue. The output type of SHA-256 is raw binary. You might be talking about human-readable hashing utilities, which output it in hex, but the vast majority of SHA-256 implementations store the data in 32 raw bytes (e.g. something like uint8_t digest[32]; in C). – forest Dec 2 '18 at 7:29
• Per its specification, "The final result of SHA-256 is a 256-bit message digest.". This same specification defines (section 3.1) what the hexadecimal representation of that is (except for whitespace and character encoding). The answer's hexadecimal representation is correct, but not the binary one (it is lacking a leading 0, which is not optional), and its decimal representation is one of several possible (none is defined by the specification). Some hashes need one more digit, thus adding leading 0 makes sense. – fgrieu Dec 3 '18 at 12:35