SHA-256 Hash Generator
Generate SHA-256 hash from any text
Input Text
SHA-256 Hash
SHA-256 hash will appear here…
What Is SHA-256 Hashing?
SHA-256 (Secure Hash Algorithm 256-bit) is a cryptographic hash function from the SHA-2 family, published by NIST in 2001 as part of FIPS 180-2 (updated in FIPS 180-4). Given any input — a single character, a multi-gigabyte file, or an empty string — SHA-256 produces a fixed 256-bit (32-byte) digest, conventionally displayed as 64 hexadecimal characters. SHA-256 is the most widely deployed hash function in production systems today, underpinning TLS certificate chains, Bitcoin’s proof-of-work, Subresource Integrity (SRI), and code-signing workflows.
SHA-256 is a one-way function: computing a hash from an input is fast (hundreds of megabytes per second on modern hardware), but reversing the process — finding an input that produces a given hash — is computationally infeasible. This property, called preimage resistance, makes SHA-256 suitable for password hashing (when combined with a salt and key-stretching), digital signatures, and data integrity verification. Unlike MD5 and SHA-1, no collision or preimage attack has been demonstrated against full SHA-256.
The SHA-2 family includes six variants: SHA-224, SHA-256, SHA-384, SHA-512, SHA-512/224, and SHA-512/256. SHA-256 operates on 32-bit words with 64 rounds per block, optimized for 32-bit processors. SHA-512 uses 64-bit words and 80 rounds, which can be faster on 64-bit platforms. For most applications where a 256-bit digest is sufficient, SHA-256 remains the default recommendation from NIST, IETF, and the CA/Browser Forum.
Why Use an Online SHA-256 Generator?
Generating a SHA-256 hash usually requires a terminal command or a few lines of code. This browser-based tool lets you compute SHA-256 digests without installing anything, switching contexts, or writing a script.
SHA-256 Use Cases
SHA-2 Family Variants Comparison
SHA-256 belongs to the SHA-2 family defined in FIPS 180-4. Each variant trades off digest size, performance characteristics, and security margin. The table below compares all SHA-2 variants you are likely to encounter.
| Variant | Digest Size | Hex Length | Byte Size | Best For |
|---|---|---|---|---|
| SHA-256 | 256 bits | 64 hex chars | 32 bytes | TLS, blockchain, code signing, JWTs, SRI |
| SHA-224 | 224 bits | 56 hex chars | 28 bytes | Truncated SHA-256 — rare, specific compliance |
| SHA-384 | 384 bits | 96 hex chars | 48 bytes | Government / CNSS, higher collision margin |
| SHA-512 | 512 bits | 128 hex chars | 64 bytes | Digital signatures, HMAC with large keys |
| SHA-512/256 | 256 bits | 64 hex chars | 32 bytes | SHA-512 speed on 64-bit CPUs, 256-bit output |
SHA-256 vs SHA-1 vs MD5 vs SHA-3
Choosing the right hash algorithm depends on your security requirements and compatibility constraints. SHA-256 occupies the practical sweet spot: it is secure, universally supported (including the Web Crypto API), and fast enough for most workloads. The comparison table below covers the properties that matter most when selecting a hash function.
| Property | SHA-256 | SHA-1 | MD5 | SHA-3-256 |
|---|---|---|---|---|
| Digest size | 256 bits (64 hex) | 160 bits (40 hex) | 128 bits (32 hex) | 256 bits (64 hex) |
| Security status | Secure | Broken (2017) | Broken (2004) | Secure |
| Collision resistance | 2^128 operations | Practical attack | Practical attack | 2^128 operations |
| Block size | 512 bits | 512 bits | 512 bits | 1600 bits (sponge) |
| Rounds | 64 | 80 | 64 | 24 |
| Standard | FIPS 180-4 | FIPS 180-4 | RFC 1321 | FIPS 202 |
| Web Crypto API | Yes | Yes | No | No |
| Primary use today | TLS, blockchain, SRI | Legacy git only | Non-security checksums | Backup standard |
How SHA-256 Works Internally
SHA-256 processes input in 512-bit (64-byte) blocks through a Merkle–Damgård construction. The algorithm initializes eight 32-bit state words (H0–H7) derived from the fractional parts of the square roots of the first eight primes. Each block passes through 64 rounds of mixing that use bitwise operations (AND, XOR, NOT, right-rotate, right-shift) and 64 round constants derived from the cube roots of the first 64 primes.
SHA-256: b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9
(256 bits = 32 bytes = 64 hex characters)
| Step | Description |
|---|---|
| Padding | Append a 1-bit, then zeros until the message length is 448 mod 512. Append the original message length as a 64-bit big-endian integer. |
| Block splitting | Divide the padded message into 512-bit (64-byte) blocks. |
| Message schedule | Expand each 16-word (32-bit) block into 64 words using sigma functions with right-rotate and right-shift operations. |
| Compression | Process 64 rounds per block using Ch, Maj, and two Sigma functions with 64 round constants derived from cube roots of the first 64 primes. |
| Output | Concatenate the eight 32-bit state words (H0-H7) into a 256-bit (32-byte) digest, rendered as 64 hexadecimal characters. |
The avalanche effect ensures that flipping a single bit in the input changes approximately 50% of the output bits. This property, combined with 2^128 collision resistance, is why SHA-256 remains the baseline recommendation for security-sensitive applications in 2026.
SHA-256 Code Examples
SHA-256 is available natively in every major language and runtime. The Web Crypto API provides it in browsers without any library. The examples below show real-world usage patterns including Unicode input handling and file hashing.
// Works in all modern browsers and Node.js 18+
async function sha256(text) {
const data = new TextEncoder().encode(text)
const hashBuffer = await crypto.subtle.digest('SHA-256', data)
const hashArray = Array.from(new Uint8Array(hashBuffer))
return hashArray.map(b => b.toString(16).padStart(2, '0')).join('')
}
await sha256('hello world')
// → "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9"
// Node.js (built-in crypto module)
const crypto = require('crypto')
crypto.createHash('sha256').update('hello world').digest('hex')
// → "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9"import hashlib
# Basic SHA-256 hash
result = hashlib.sha256(b'hello world').hexdigest()
print(result) # → "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9"
# Hash a string (encode to bytes first)
text = 'café ☕'
hashlib.sha256(text.encode('utf-8')).hexdigest()
# → "3eb53e00aa1bb4b1e8aab1ab38e56e6b8fb0b20e1cf7e1d19f36e4fad2537445"
# Hash a file in chunks (memory-efficient)
with open('release.tar.gz', 'rb') as f:
sha = hashlib.sha256()
for chunk in iter(lambda: f.read(8192), b''):
sha.update(chunk)
print(sha.hexdigest())package main
import (
"crypto/sha256"
"fmt"
)
func main() {
data := []byte("hello world")
hash := sha256.Sum256(data)
fmt.Printf("%x\n", hash)
// → b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9
}# Using sha256sum (Linux) or shasum (macOS) echo -n "hello world" | sha256sum # → b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9 - # macOS echo -n "hello world" | shasum -a 256 # → b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9 - # Verify a file checksum echo "b94d27b... myfile.bin" | sha256sum -c # → myfile.bin: OK # Using openssl (cross-platform) echo -n "hello world" | openssl dgst -sha256 # → SHA2-256(stdin)= b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9