Hash Generator — MD5, SHA-1, SHA-256 & SHA-512 Explained
Learn how hash functions work, the differences between MD5, SHA-1, SHA-256, and SHA-3, which algorithm to use for file verification vs. passwords, and how to generate hashes instantly with a free tool.
By sadiqbd · June 6, 2026
Hashing is one of the most fundamental tools in computing — and regularly misunderstood
MD5, SHA-1, SHA-256, SHA-512, SHA-3 — these names come up constantly in security documentation, file verification, API authentication, and data integrity checks. But what a hash function actually does, why it matters, and which one to use for what purpose trips up developers more often than it should.
A hash generator lets you produce a hash of any input string instantly. More importantly, understanding what each algorithm produces — and the crucial differences between them — helps you make better decisions in your code.
What Is a Hash Function?
A hash function takes an input of any length and produces a fixed-length output — the hash (also called a digest or checksum). The same input always produces the same hash; different inputs should produce different hashes.
Four properties define a cryptographically useful hash function:
- Deterministic: same input → same output, always.
- Fast to compute: even large inputs hash quickly.
- Pre-image resistant: given a hash, it should be computationally infeasible to find the original input.
- Collision resistant: two different inputs should not produce the same hash.
The Major Hash Algorithms
MD5 (Message Digest 5)
- Output length: 128 bits = 32 hex characters
- Speed: very fast
- Security status: broken for cryptographic use. Collisions (two different inputs producing the same MD5 hash) can be generated in seconds on modern hardware.
- Still useful for: checksums where collision resistance isn't critical (file integrity verification where the file itself isn't being attacked, non-security data deduplication).
- Not suitable for: passwords, digital signatures, security tokens.
Example: MD5("hello") = 5d41402abc4b2a76b9719d911017c592
SHA-1 (Secure Hash Algorithm 1)
- Output: 160 bits = 40 hex characters
- Security status: deprecated. Practical collision attacks exist (Google's SHAttered attack in 2017 produced two different PDF files with the same SHA-1). Removed from TLS and code signing.
- Still found in: old Git commits (Git is migrating to SHA-256), legacy systems.
- Not suitable for: anything new requiring collision resistance.
SHA-256 (SHA-2 family)
- Output: 256 bits = 64 hex characters
- Security status: secure. No known practical attacks.
- Used for: TLS certificates, code signing, file integrity, HMAC in APIs, Bitcoin proof-of-work.
- The right default for most modern hash needs.
Example: SHA-256("hello") = 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
SHA-512 (SHA-2 family)
- Output: 512 bits = 128 hex characters
- Speed: slower than SHA-256 on 32-bit systems; comparable on 64-bit.
- Used when: extra security margin is desired, or 64-bit throughput is a priority.
SHA-3 (Keccak)
- Output: configurable (SHA3-256, SHA3-512, etc.)
- Security status: secure. Designed as an alternative to SHA-2 in case SHA-2 is ever compromised; uses a fundamentally different algorithm (sponge construction).
- Adoption: growing but not yet dominant; SHA-256 is still the default in most contexts.
How to Use the Hash Generator on sadiqbd.com
- Enter the text you want to hash.
- Select the algorithm — MD5, SHA-1, SHA-256, SHA-512, etc.
- Read the hash — the output appears instantly.
- Copy and use in your application.
Most implementations also allow toggling between uppercase and lowercase hex output, and some support HMAC mode (keyed hashing for API authentication).
Real-World Examples
File integrity verification
You download a software package. The vendor publishes a SHA-256 checksum:
a3f5c... (64 hex chars)
After downloading, you hash the file and compare. If they match, the file wasn't corrupted or tampered with in transit. If they don't match — don't install it.
The hash generator handles text inputs; for file hashing you'd use a command-line tool or a dedicated file hash checker.
API request signing with HMAC
Many REST APIs require an HMAC-SHA256 signature to verify that requests come from a legitimate client.
HMAC (Hash-based Message Authentication Code) combines a hash function with a secret key:
HMAC-SHA256(key, message) → authentication code
The hash generator with HMAC mode: enter the message and key, get the signature to include in your API request header.
Generating a cache key
You need a cache key that's unique for each unique combination of user ID, request parameters, and timestamp, but short enough to use as a Redis key.
SHA-256("user_123:filter=active:page=2") → a7b3f9c... (64 chars)
Use the first 16–32 characters for a shorter key if needed. SHA-256 provides enough entropy that truncation is safe for non-security purposes.
Password reset tokens (don't use just a hash)
A common pattern for password reset: generate a random token, store its SHA-256 hash in the database, email the raw token. When the user clicks the link, hash the received token and compare against the stored hash.
This way, even if the database is breached, the attacker can't reverse the hash to get valid reset tokens. The hash generator is useful for testing this logic manually.
Data deduplication
You're storing documents and want to detect duplicates. Hash each document with SHA-256 and store the hash. If two documents produce the same SHA-256 hash, they're either identical or you've found an extraordinarily unlikely collision (SHA-256 collision has never been demonstrated).
Which Hash Algorithm Should You Use?
| Use case | Recommended |
|---|---|
| Password storage | bcrypt, scrypt, or Argon2 (not any SHA variant) |
| File checksums | SHA-256 |
| Digital signatures / TLS | SHA-256 |
| API request signing | HMAC-SHA256 |
| Data deduplication | SHA-256 or SHA-1 (OK for this) |
| Git-compatible hashing | SHA-1 (legacy) or SHA-256 (new) |
| Anything new | SHA-256 as default |
| Avoid for security | MD5, SHA-1 |
Note: SHA-256 is not suitable for password hashing because it's too fast — attackers can hash billions of guesses per second on GPU hardware. Use bcrypt, scrypt, or Argon2 for passwords.
Tips for Working With Hashes
Hash functions are one-way. You cannot reverse a SHA-256 hash to get the input. If you need to retrieve the original data, don't hash it — encrypt it instead.
Even one character difference completely changes the hash. SHA-256("hello") ≠ SHA-256("Hello"). This is called the avalanche effect and is intentional — it makes hashes useful for detecting any change in data.
Always use a secure comparison function. When comparing hashes in code, use a constant-time comparison function (like hmac.compare_digest() in Python) rather than ==. String equality in most languages short-circuits on the first differing character, which can enable timing attacks.
Salted hashing for lookups. If you need to look up records by a hashed value (e.g., finding a user by email hash), add a consistent application-level salt — otherwise a dictionary attack against your hash column is trivial.
Frequently Asked Questions
Can two different inputs produce the same hash (collision)? Theoretically yes for any hash function (by the pigeonhole principle — there are infinite inputs but finite possible outputs). In practice, SHA-256 collisions are computationally infeasible. MD5 and SHA-1 collisions have been demonstrated and should not be trusted for security.
What's the difference between hashing and encryption? Hashing is one-way — you can't get the original data back. Encryption is two-way — you can decrypt back to the original with the right key. Use hashing for verification; use encryption for confidentiality.
Why shouldn't I use SHA-256 for passwords? SHA-256 is too fast — modern GPUs can compute billions of SHA-256 hashes per second, making brute-force attacks against password databases practical. Use bcrypt, Argon2, or scrypt, which are deliberately slow.
What is HMAC? Hash-based Message Authentication Code. It combines a hash function with a secret key to produce a message authentication code — useful for verifying both the integrity and the authenticity of a message.
Is the hash generator free? Yes — completely free, runs in your browser, no sign-up required.
Hash functions are fundamental to web security, data integrity, and API authentication. Knowing which algorithm to use for which purpose — and why MD5 is a bad choice for security despite still appearing everywhere — is practical knowledge that pays off throughout a development career.
Try the Hash Generator free at sadiqbd.com — generate MD5, SHA-1, SHA-256, SHA-512, and SHA-3 hashes instantly.