What is the SHA-256 hash of a single 1 bit?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
This question has an important ambiguity: do you mean a literal one-bit message, or do you mean one byte whose value is 0x01? Those are different inputs, and SHA-256 hashes them to different digests because the algorithm is defined over exact bitstrings, including their original length.
The Input Definition Matters
A single byte with value 0x01 is the 8-bit string:
00000001
A literal one-bit message is only:
1
Those are not the same message. Since SHA-256 includes padding and appends the original message length in bits, the final processed blocks differ greatly.
That is why cryptographic hash questions must define the input precisely before giving an answer.
The SHA-256 Digest of a Literal One-Bit Message
For the one-bit message 1, the SHA-256 digest is:
b9debf7d52f36e6468a54817c1fa071166c3a63d384850e1575b42f702dc5aa1
This is the digest of the bitstring whose total length is exactly 1 bit before padding.
That detail matters because SHA-256 appends the original bit length at the end of the padded message block. A one-bit message therefore has a different padded representation from a one-byte message with value 0x01.
The Digest of the Byte 0x01
If you hash one byte whose value is 0x01, the digest is:
4bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459a
You can reproduce that with a normal byte-oriented library such as Python's standard hashlib:
That code is correct for the one-byte input 0x01. It is not the digest of a literal one-bit message.
Why Normal APIs Do Not Help with a One-Bit Message
Most everyday hash APIs take bytes, not arbitrary bit-length streams. That means you cannot ask them directly to hash a message of length 1 bit unless you implement or use a bit-level hashing interface.
This is why many developers accidentally answer the byte question instead of the bit question.
The formal SHA-256 algorithm accepts bitstrings, so a one-bit message is valid in the specification. The difficulty is practical API support, not the underlying definition.
How the Padding Differs
SHA-256 message padding works by:
- appending a single
1bit - appending enough
0bits to reach the right length - appending the original message length as a 64-bit value
So for the message 1, the original length is 1.
For the message 00000001, the original length is 8.
Even though both inputs contain a 1, they produce different padded blocks because the starting bitstrings and bit lengths are different. Once the padded block changes, the digest changes too.
Another Common Confusion: The Text String "1"
The ASCII text string "1" is not the same as the bit 1 or the byte 0x01. In ASCII or UTF-8, the text string "1" is the byte 0x31.
So this produces yet another digest:
This is a good example of why cryptographic answers should always specify:
- bitstring or byte string
- byte value or text encoding
- exact length of the input
Without that, two people can both compute a hash correctly and still disagree because they hashed different data.
A Simple Way to Think About It
When a cryptographic question says "single 1 bit," read it literally unless the surrounding context clearly says otherwise. If the question instead says "the byte 0x01," then a normal byte-oriented hashing library is fine.
In short:
- bit-level question means literal bitstring semantics
- byte-level question means library input such as
bytes([0x01])
That distinction is the entire reason the digests differ.
Common Pitfalls
The most common mistake is using a byte-oriented library and assuming it hashed one bit when it actually hashed one full byte.
Another issue is treating the text string "1" as if it were the same as the numeric byte 0x01. It is not.
People also overlook that SHA-256 padding depends on the original message length in bits. That is exactly why the one-bit and one-byte cases diverge.
Finally, when publishing or verifying a digest, always state the input representation explicitly. Otherwise the number may be correct for a different message than the one being discussed.
Summary
- A literal one-bit message is not the same input as the one-byte value
0x01. - The SHA-256 digest of the one-bit message
1isb9debf7d52f36e6468a54817c1fa071166c3a63d384850e1575b42f702dc5aa1. - The SHA-256 digest of the byte
0x01is4bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459a. - Most common hash APIs work on bytes, not arbitrary bit-length messages.
- Always define the exact input representation before discussing a cryptographic hash.

