How to Generate SHA-256 and MD5 Hashes
A hash function takes any input โ a password, a file, a message โ and produces a fixed-length string of characters that uniquely represents that input. The same input always produces the same hash, but you can't reverse the hash to recover the original input. This one-way property makes hashing essential for password storage, file integrity verification, and digital signatures.
- Generate SHA-256, SHA-512, and MD5 hashes from any text.
- How Hashing Works.
- Covers common hash algorithms.
- Covers hashing in javascript.
- When to Use Hashing.
How Hashing Works
A hash function processes input data through a mathematical algorithm that produces a fixed-size output regardless of input size. SHA-256 always outputs 256 bits (64 hex characters). MD5 always outputs 128 bits (32 hex characters). A single character change in the input produces a completely different hash โ this is called the avalanche effect. 'hello' and 'Hello' produce entirely different hashes.
Common Hash Algorithms
SHA-256 is the current standard for security-sensitive applications. It's used in TLS certificates, Bitcoin, and password hashing. SHA-512 offers a larger output (128 hex characters) and is slightly faster on 64-bit processors. MD5 is fast but cryptographically broken โ collisions can be generated intentionally. Use MD5 only for checksums and non-security purposes (file integrity verification, cache keys). Never use MD5 for passwords.
Hashing in JavaScript
The Web Crypto API provides native hashing in browsers:
background-size animation or @property registered custom properties instead.async function sha256(message) {
const data = new TextEncoder().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('');
}
For quick hash generation without code, use the Hash Generator tool โ paste any text and get SHA-256, SHA-512, and MD5 hashes instantly.
When to Use Hashing
Password storage: hash passwords with bcrypt or Argon2 (not raw SHA-256) before storing in a database. File integrity: compare SHA-256 hashes of downloaded files against published checksums to verify they haven't been tampered with. Data deduplication: hash file contents to detect duplicates without comparing full file contents. Cache keys: hash request parameters to create unique cache identifiers.