Hash Generator

Generate MD5, SHA-1, SHA-256, SHA-512, and bcrypt hashes. Runs entirely in your browser — nothing is sent to a server.

Text Input
hash a file:or drag & drop
0 chars0 bytes
Algorithmlegacy
#
enter text or drop a file

How to generate a hash

  1. Type or paste your text into the left panel. Hashes update live as you type — no button required for MD5, SHA-1, SHA-256, and SHA-512.
  2. Select the algorithm using the dropdown in the right panel. Not sure which to choose? See the comparison table below.
  3. Copy the hash using the copy button. The ⚙ settings panel lets you toggle between uppercase and lowercase output.
  4. To hash a file, drag and drop it onto the drop zone at the bottom of the input panel or click "choose file". The file is read in your browser — it is never uploaded anywhere.
  5. To verify a hash, paste a known hash into the verify field below the output. The tool compares it against the computed hash and shows a match or no-match result instantly.

Choosing the right hashing algorithm

Each algorithm is designed for a different purpose. Using the wrong one is one of the most common security mistakes in web development — particularly storing passwords with SHA-256.

AlgorithmOutputSpeedSecurityUse forNever use for
MD5128-bit / 32 hex charsVery fastBrokenNon-security checksums, cache keys, deduplicationPasswords, signatures, certificates
SHA-1160-bit / 40 hex charsFastDeprecatedLegacy system compatibility onlyAny new application
SHA-256256-bit / 64 hex charsFastStrongFile integrity, API signatures, JWT, TLS certificates, HMACPassword storage (too fast — see below)
SHA-512512-bit / 128 hex charsFastStrongHigh-security data integrity, longer hash output requiredPassword storage
bcrypt60-char string (includes salt)Deliberately slowRecommended for passwordsPassword hashing onlyFile checksums, data integrity (use SHA-256 instead)

Why SHA-256 is the wrong choice for passwords

SHA-256 is a strong, collision-resistant algorithm — but it was designed to be fast. That speed is exactly the problem for passwords.

A modern consumer GPU can compute roughly 8 billion SHA-256 hashes per second. An attacker who steals your password database can test every word in a dictionary, every common password, and millions of variations in under a minute — even if you add a salt.

bcrypt is deliberately slow. At cost factor 12, a single bcrypt hash takes roughly 400ms on commodity hardware. That rate-limits an attacker to approximately 2–3 guesses per second per machine, making offline brute-force attacks economically impractical for strong passwords.

The OWASP Password Storage Cheat Sheet recommends bcrypt, scrypt, or Argon2id for password hashing. All three share the same property: adjustable slowness that scales with hardware improvements.

bcrypt cost factor guide

Each increment to the cost factor doubles the computation time. The goal is to make login feel instant to a human (~400ms is imperceptible) while making offline attacks expensive. Increase the cost factor as hardware gets faster — benchmark your production server and pick the highest value that keeps login under 1 second.

Cost factorApprox. timeRecommendation
4~1msUnit tests only — never production
10~100msLow-traffic apps, acceptable trade-off
12default~400msDefault — recommended for most applications
13~800msHigher security, noticeable on high-traffic login endpoints
14~1.6sHigh-security systems — test your server capacity first

What a hash function actually does

A hash function takes any input — a single character, a 10GB file, a password — and produces a fixed-length output called a digest. Three properties define a cryptographic hash function:

DeterministicThe same input always produces the same output. "hello" will always hash to the same SHA-256 value, on every machine, in every language.
One-wayGiven a hash, there is no algorithm to recover the original input. The only way to "crack" a hash is to guess the input, hash it, and compare — which is why password hashing needs to be slow.
Collision-resistantTwo different inputs should not produce the same hash. MD5 and SHA-1 have known collisions — researchers have found pairs of different files that hash identically — which is why they are deprecated for security use.

Hashing is not encryption. Encryption is reversible given a key. Hashing is intentionally irreversible. Use hashing when you need to verify data without storing the original; use encryption when you need the original data back.

Real-world use cases

Verifying a downloaded fileSHA-256
Open-source projects publish a SHA-256 checksum alongside each release. After downloading, hash the file here and compare against the published value. A mismatch means the file was corrupted in transit or tampered with.
Storing user passwords in a databasebcrypt
Never store plain-text passwords or SHA-256 passwords. Hash with bcrypt (cost 12) and store the full 60-character output — salt included. When a user logs in, use bcrypt.compare() against the stored hash. The salt is embedded in the hash string so you do not store it separately.
Generating a cache key or ETagsMD5
MD5 is fast and produces a short, consistent fingerprint — ideal for cache invalidation keys, ETag headers, or deduplicating records where security is not a concern. A URL plus query parameters hashed to MD5 is a practical cache key.
Signing API requests (HMAC)SHA-256
Most webhook systems and payment APIs use HMAC-SHA256 to sign requests. The server computes HMAC-SHA256(secret, payload) and sends the result in a header. The receiver recomputes and compares. SHA-256 is the standard choice — SHA-512 is accepted where higher security margins are required.
Deduplicating large datasetsSHA-256 or MD5
When ingesting files or records, hash each item and store the hash in a lookup table. Before inserting, check for an existing hash. MD5 is fast enough for non-adversarial deduplication; SHA-256 is safer if collisions would cause data loss or a security issue.

Common hashing mistakes

Three of the four mistakes below can lead directly to a data breach. The fourth causes silent bugs that are hard to diagnose.

Using SHA-256 to hash passwordsmost critical
Wrong
// Storing user passwords — DO NOT do this
const hash = await crypto.subtle.digest(
  "SHA-256",
  new TextEncoder().encode(password)
)
Correct
// Correct: use bcrypt with cost ≥ 12
import bcrypt from "bcryptjs"
const hash = await bcrypt.hash(password, 12)

Modern GPUs compute roughly 8 billion SHA-256 hashes per second. An attacker with a leaked database can brute-force common passwords in seconds — even with a salt. bcrypt is deliberately slow: at cost 12, a single hash takes ~400ms on commodity hardware, limiting an attacker to roughly 2–3 attempts per second per machine.

Comparing hashes as case-sensitive strings
Wrong
// Will fail if one hash is uppercase and the other is lowercase
if (storedHash === incomingHash) { ... }
Correct
// Normalise both to the same case before comparing
if (storedHash.toLowerCase() === incomingHash.toLowerCase()) { ... }

SHA hashes are hexadecimal strings. Some systems output uppercase (A1B2C3), others lowercase (a1b2c3). They represent the same value. Always normalise to the same case — or use a constant-time comparison function to avoid timing attacks.

Hashing a password with bcrypt for file integrity
Wrong
// bcrypt truncates input at 72 bytes
const fileHash = await bcrypt.hash(fileContents, 12)
Correct
// Use SHA-256 for files — fast and collision-resistant
const hash = await crypto.subtle.digest(
  "SHA-256", fileBuffer
)

bcrypt silently truncates input at 72 bytes. Two different files that share the same first 72 bytes will produce the same bcrypt hash. bcrypt is designed for short secrets (passwords), not arbitrary data. Use SHA-256 or SHA-512 for file integrity.

Expecting the same bcrypt hash twice
Wrong
// This will always be false — bcrypt includes a random salt
bcrypt.hash("password", 12) === bcrypt.hash("password", 12)
Correct
// Always use compare — never hash again and compare
const match = await bcrypt.compare(plaintext, storedHash)

Every bcrypt call generates a new random salt, producing a different 60-character hash even for identical input. To verify a password, use bcrypt.compare(plaintext, storedHash) — it extracts the salt from the stored hash, recomputes, and compares internally.

Related tools

Frequently asked questions

What is the difference between hashing and encryption?

Encryption is reversible — given the key, you can decrypt ciphertext back to plaintext. Hashing is a one-way function: it produces a fixed-length digest from any input, and there is no algorithm to recover the original input from the hash alone. You use encryption when you need the original data back (e.g. storing an API key you will later use). You use hashing when you only need to verify data (e.g. passwords, file integrity).

Which hashing algorithm should I use for passwords?

Use bcrypt (cost factor 12 or higher), scrypt, or Argon2id. These are specifically designed for password hashing — they are slow by design, include a salt automatically, and resist GPU and ASIC brute-force attacks. The OWASP Password Storage Cheat Sheet recommends all three. Never use MD5, SHA-1, SHA-256, or SHA-512 for password storage — they are too fast.

Which hashing algorithm should I use for file integrity?

SHA-256 is the standard choice for file integrity verification. It is fast, collision-resistant, and widely supported. SHA-512 is acceptable for higher security margins. Avoid MD5 and SHA-1 for security-sensitive integrity checks — both have known collision vulnerabilities where two different inputs can produce the same hash.

Why does bcrypt produce a different hash every time for the same input?

bcrypt automatically generates a random 128-bit salt for each call and embeds it into the output hash string. This is intentional — it means two users with the same password have different stored hashes, preventing rainbow table attacks. To verify a password, always use bcrypt.compare(plaintext, storedHash). Never hash the password again and compare the two hashes.

What is the bcrypt cost factor and how do I choose it?

The cost factor (also called rounds or work factor) controls how slow bcrypt is. Each increment doubles the computation time. Cost 12 takes roughly 400ms and is the recommended default for most web applications. Increase it as hardware gets faster — the goal is to keep login time under 1 second while making offline brute-force attacks computationally expensive.

Is MD5 safe to use?

MD5 is safe for non-security uses: cache keys, ETags, deduplication fingerprints, and non-cryptographic checksums. It is broken for any security-sensitive use. Researchers demonstrated MD5 collision attacks in 2004, and tools to find collisions are publicly available. Never use MD5 for password hashing, digital signatures, or verifying software authenticity.

Does this tool send my data to a server?

No. All hashing runs in your browser. SHA-1, SHA-256, and SHA-512 use the browser's built-in Web Crypto API (window.crypto.subtle), which never leaves the JavaScript sandbox. MD5 runs via a pure-JavaScript implementation. bcrypt runs via the bcryptjs library, also entirely in-browser. You can disconnect from the internet after loading the page and the tool will continue to work.

Why is SHA-256 not safe for passwords even though it is cryptographically strong?

SHA-256 is a general-purpose hash function optimised to be fast. A modern GPU can compute roughly 8 billion SHA-256 hashes per second. An attacker who steals your password database can test every common password and variation in seconds. bcrypt is orders of magnitude slower by design — at cost 12, a single bcrypt hash takes ~400ms, limiting an attacker to roughly 2–3 guesses per second per machine regardless of hardware.