Looking to generate a SHA-256 hash online for free or calculate a text fingerprint to verify its integrity? SHA-256 has become the de facto standard for cryptographic hashing. From Bitcoin blockchain to digital signatures to file integrity verification, this algorithm is ubiquitous in modern security.
Unlike MD5 and SHA-1, now considered vulnerable, SHA-256 remains cryptographically secure. That’s why it’s used for SSL certificates and download validation (but on its own it is not suitable for password storage, as we will see below).
Our hash generator is a hash tool for developers that instantly calculates MD5, SHA-1, SHA-256, and SHA-512 directly in your browser, without sending your data to any server. Discover in this article how SHA-256 works and when to use it.
What is a Hash Function?
A hash function transforms data of any size into a fixed-size fingerprint, called a hash, digest or fingerprint.
Input: "Hello world!"
↓ SHA-256
Hash: c0535e4be2b79ffd93291305436bf889314e4a3faec05ecffcbb7df31ad9e51a
(64 hexadecimal characters = 256 bits)
The hash is often compared to a fingerprint: practically unique for each data, but impossible to reconstruct the person from the fingerprint.
Fundamental Properties of SHA-256
1. Determinism
The same input always produces the same hash:
SHA256("test") → "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"
SHA256("test") → "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"
// Identical, always
2. Avalanche Effect
A tiny change in input radically modifies the hash:
SHA256("test") → "9f86d081884c7d659a2feaa0c55ad015..."
SHA256("Test") → "532eaabd9574880dbf76b9b8cc00832c..."
SHA256("test ") → "231aa78c52a74a572e40f4a5dcdf2496..."
// Totally different!
Test this effect with our hash generator.
3. Irreversibility (One-way Function)
It is practically impossible to find the input from the hash: one can only guess inputs and compare their hashes. This is the fundamental difference with encoding (like Base64, which is reversible).
4. Collision Resistance
Two different inputs cannot produce the same hash (in practice). Collisions necessarily exist, but with 2^256 possible values, finding one would take about 2^128 computations (birthday paradox): this is out of reach.
5. Fixed Size
Whatever the input size, the hash is always 256 bits:
SHA256("a") → 64 hex characters
SHA256("Lorem ipsum dolor sit amet...") → 64 hex characters
SHA256(10 GB file) → 64 hex characters
SHA-256 vs Other Algorithms
Comparison Table
| Algorithm | Hash Size | 2025 Security | Speed |
|---|---|---|---|
| MD5 | 128 bits | Broken | Very fast |
| SHA-1 | 160 bits | Deprecated | Fast |
| SHA-256 | 256 bits | Secure | Medium |
| SHA-384 | 384 bits | Secure | Slower |
| SHA-512 | 512 bits | Secure | Slower |
| SHA-3 | Variable | Secure | Variable |
| BLAKE3 | 256 bits | Secure | Very fast |
MD5: Why to Avoid It
MD5 is no longer considered safe since 2004:
- Collisions found in seconds
- Should never be used for security
- Acceptable only for non-critical checksums (e.g., detecting accidental corruption, not malicious tampering)
SHA-1: Deprecated
SHA-1 was publicly broken in 2017 (SHAttered project):
- Google produced two PDFs with the same SHA-1 hash
- Browsers refuse SHA-1 certificates since 2017
- Git is gradually migrating to SHA-256 (SHA-256 repositories are already possible, and Git 3.0 is set to make it the default for new repositories)
SHA-256: The Current Standard
SHA-256 is part of the SHA-2 family, designed by the NSA, published in 2001 and standardized in 2002 (FIPS 180-2). No known practical vulnerabilities.
SHA-256 Use Cases
1. File Integrity Verification
Verify that a file hasn’t been altered during download:
# Calculate hash of a downloaded file
sha256sum ubuntu-24.04-desktop-amd64.iso
# Compare with official hash
# If identical → file is intact
Official sites often publish SHA-256 hashes of their downloads.
2. Password Storage (with Precautions)
SHA-256 alone is NOT sufficient for passwords. Use:
- Argon2id: Recommended variant of Argon2, winner of the Password Hashing Competition
- bcrypt: Designed for passwords, intentionally slow
- scrypt: Resistant to hardware attacks
- PBKDF2: When FIPS compliance is required, with at least 600,000 iterations (PBKDF2-HMAC-SHA256, OWASP recommendation)
// ❌ Bad: SHA-256 alone
const hash = sha256(password);
// ❌ Better but insufficient: SHA-256 with salt
const hash = sha256(password + salt);
// ✅ Correct: bcrypt (intentionally slow)
const hash = await bcrypt.hash(password, 12);
To understand the difference between hashing and encoding, read our article on Base64 security.
3. Digital Signatures
SSL/TLS certificates use SHA-256 to sign data:
Data → SHA-256 Hash → Signature with private key → Verifiable signature
4. Blockchain and Bitcoin
Bitcoin uses SHA-256 extensively:
- Block and transaction hashing (double SHA-256)
- Proof of Work (mining)
- Classic addresses (SHA-256 followed by RIPEMD-160)
5. HMAC-SHA256
Combine SHA-256 with a secret key for message authentication:
const crypto = require('crypto');
const hmac = crypto.createHmac('sha256', secretKey)
.update(message)
.digest('hex');
Used in:
- JWT (JSON Web Tokens)
- API authentication (AWS Signature v4)
- Webhook verification
6. Derived Key Generation
Transform a password into an encryption key:
// PBKDF2 with SHA-256
const key = await crypto.subtle.deriveKey(
{ name: 'PBKDF2', hash: 'SHA-256', iterations: 600000, salt },
passwordKey,
{ name: 'AES-GCM', length: 256 },
false,
['encrypt', 'decrypt']
);
Implementation in Different Languages
JavaScript (Browser and Node.js)
// Browser - Web Crypto API
async function sha256(message) {
const encoder = new TextEncoder();
const data = encoder.encode(message);
const hash = await crypto.subtle.digest('SHA-256', data);
return Array.from(new Uint8Array(hash))
.map(b => b.toString(16).padStart(2, '0'))
.join('');
}
// Node.js
const crypto = require('crypto');
const hash = crypto.createHash('sha256').update('message').digest('hex');
Python
import hashlib
# Hash a string
hash = hashlib.sha256("message".encode()).hexdigest()
# Hash a file
with open("file.txt", "rb") as f:
hash = hashlib.sha256(f.read()).hexdigest()
PHP
// Hash a string
$hash = hash('sha256', 'message');
// Hash a file
$hash = hash_file('sha256', 'file.txt');
Bash
# Hash a string
echo -n "message" | sha256sum
# Hash a file
sha256sum file.txt
Best Practices
1. Choose the Right Algorithm for the Right Use
| Usage | Recommended Algorithm |
|---|---|
| Passwords | Argon2id, bcrypt, scrypt, PBKDF2 |
| File integrity | SHA-256, BLAKE3 |
| Signatures | SHA-256, SHA-384 |
| Fast checksums | BLAKE3, xxHash |
| Derived keys | PBKDF2-SHA256, Argon2 |
2. Never Invent Your Own Scheme
// ❌ Bad: homemade scheme
const hash = sha256(sha256(password) + username + "my_secret_salt");
// ✅ Correct: use a proven library
const hash = await bcrypt.hash(password, 12);
3. Use Constant-Time Comparisons
To avoid timing attacks:
// ❌ Bad: standard comparison
if (userHash === storedHash) { ... }
// ✅ Correct: constant-time comparison
const crypto = require('crypto');
if (crypto.timingSafeEqual(Buffer.from(userHash), Buffer.from(storedHash))) { ... }
4. Document Algorithms Used
Prefix your hashes to identify the algorithm:
$sha256$e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
Or use standard formats like the PHC string format (from the Password Hashing Competition).
Frequently Asked Questions
Can SHA-256 be “decrypted”?
No. SHA-256 is not encryption but hashing. There’s no key to “decrypt”. The only way to find the input is to test all possibilities (brute force) or use rainbow tables.
Why shouldn’t passwords use SHA-256 alone?
SHA-256 is too fast! An attacker can test billions of combinations per second. bcrypt and Argon2 are intentionally slow to counter this.
Will SHA-256 be broken someday?
No known practical attack to date. A quantum computer (Grover’s algorithm) would at best reduce the search for an input matching a given hash from 2^256 to about 2^128 operations, which remains out of reach. The post-quantum algorithms standardized by NIST in 2024 mainly aim to replace public-key encryption and signatures (RSA, elliptic curves), not hash functions.
Complementary Tools
To work with hash functions:
- Hash Generator: Calculate MD5, SHA-1, SHA-256, SHA-512 instantly
- Password Generator: Create strong passwords to hash
- Base64 Encoder: Warning, encoding ≠ hashing!
- Diff Checker: Check line by line whether two hashes (or lists of hashes) match
Conclusion
SHA-256 is the cornerstone of modern cryptography. Its properties – determinism, avalanche effect, irreversibility, collision resistance – make it the algorithm of choice for integrity verification, digital signatures and many other applications.
However, remember: the right tool for the right use. For passwords, prefer bcrypt or Argon2 which are designed specifically for this purpose.
Test our hash generator now to calculate your SHA-256 fingerprints!