Try it Live
Run SHA256 examples in the interactive playground
SHA256 Test Vectors
Official NIST FIPS 180-4 test vectors and additional validation cases for SHA-256.NIST FIPS 180-4 Test Vectors
Empty String
Input:"" (zero bytes)
Expected Output:
Single Byte “abc”
Input:"abc" (3 bytes)
Expected Output:
“hello world”
Input:"hello world" (11 bytes)
Expected Output:
448-bit Message
Input:"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" (56 bytes)
This message is exactly 448 bits (56 bytes), which tests padding behavior when the message is close to a block boundary.
Expected Output:
This 448-bit message specifically tests SHA-256’s padding scheme. After the message, SHA-256 appends a ‘1’ bit, then zeros, then a 64-bit length field. This message length requires careful padding handling.
896-bit Message
Input:"abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu" (112 bytes)
This 896-bit message tests multi-block processing (two 512-bit blocks).
Expected Output:
One Million ‘a’ Characters
Input Description
Input: 1,000,000 repetitions of the character ‘a’ This tests hashing of large inputs and validates that the implementation correctly processes multiple blocks. Expected Output:Bitcoin-Specific Test Vectors
Genesis Block Hash
Bitcoin’s genesis block header (double SHA-256): Input: 80-byte block header (hex):Edge Cases
Single Byte (0x00)
Input:0x00 (1 byte of zeros)
Expected Output:
All Zeros (32 bytes)
Input: 32 bytes of zeros Expected Output:All Ones (32 bytes)
Input: 32 bytes of 0xFF Expected Output:Unicode Test Vectors
UTF-8 Emoji
Input:"🚀" (rocket emoji, 4 bytes in UTF-8: 0xF0 0x9F 0x9A 0x80)
Expected Output:
Chinese Characters
Input:"你好" (hello in Chinese, 6 bytes in UTF-8)
Verification:
Streaming API Test Vectors
Chunked vs One-Shot
Verify that streaming API produces identical results to one-shot hashing:Implementation Validation
Cross-Implementation Comparison
Compare results with well-known implementations:See Also
- SHA256 API Reference - Complete API documentation
- Security - Security properties and analysis
- Performance - Benchmarks and optimization tips
- NIST FIPS 180-4 - Official specification

