โ† Back to Blog

What Is SHA256 Hash?

2026-04-03 ยท 5 min read

Introduction to SHA256

SHA256 (Secure Hash Algorithm 256-bit) is a member of the SHA-2 hash function family, designed by the US National Security Agency (NSA) and published by NIST in 2001. SHA256 converts input of any length into a 256-bit (64 hexadecimal characters) hash value. It is one of the most widely used hash algorithms in internet infrastructure today.

SHA256("hello") =
2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824

SHA256("Hello") =
185f8db32921bd46d35a569dd56f9b9c9f6b0a37bbbb6e0e12e7e2430ee4a998

SHA256("") =
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855

Security Strength of SHA256

SHA256's 256-bit output means there are 2^256 possible hash values (approximately 1.16 ร— 10^77). Finding a collision through brute force would theoretically require about 2^128 computations โ€” impossible to complete even using all computers on Earth for hundreds of millions of years. No known practical collision attacks exist, and SHA256 is still considered a cryptographically secure hash function.

How SHA256 Works

SHA256 uses the Merkle-Damgรฅrd construction, with processing steps including: padding input to a multiple of 512 bits, splitting data into 512-bit blocks, using 64 constants (fractional parts of cube roots of the first 64 primes) and 8 initial hash values (fractional parts of square roots of the first 8 primes), and processing each data block through 64 rounds of compression. Each round uses bitwise operations, modular addition, and shifts to produce the final 256-bit output.

Main Application Scenarios for SHA256

SHA256 and the SHA-2 Family

The SHA-2 family includes multiple variants, with numbers indicating output bit length: SHA-224 (224 bits, 28 bytes), SHA-256 (256 bits, 32 bytes), SHA-384 (384 bits, 48 bytes), SHA-512 (512 bits, 64 bytes), and SHA-512/224 and SHA-512/256 (computed using SHA-512, truncated to shorter output). SHA-256 and SHA-512 are most widely used โ€” SHA-256 performs better on 32-bit systems, while SHA-512 is sometimes faster on 64-bit systems.

SHA-3: Successor to SHA256?

In 2012, NIST announced the Keccak algorithm as the SHA-3 standard. SHA-3's design is completely different from SHA-2 (using sponge construction rather than Merkle-Damgรฅrd), providing structural diversity โ€” if a design flaw in SHA-2 is discovered, SHA-3 would still be secure. However, no serious vulnerabilities have been found in SHA-256, and SHA-3 hasn't shown a trend of replacing SHA-256 โ€” both coexist in different application scenarios.

Using SHA256 in Code

// JavaScript (Node.js)
const crypto = require('crypto');
const hash = crypto.createHash('sha256').update('hello').digest('hex');
// '2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824'

// Python
import hashlib
hash = hashlib.sha256(b'hello').hexdigest()
# '2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824'

// Go
import "crypto/sha256"; import "fmt"
hash := fmt.Sprintf("%x", sha256.Sum256([]byte("hello")))

Try the free tool now

Use Free Tool โ†’