SHA-256 / MD5 Hash Generator

Hashing runs entirely in your browser. No data is uploaded, logged, or stored.
Drop a file here or click to select

What is a Cryptographic Hash?

A cryptographic hash function takes an input of any size and produces a fixed-length string of characters — the digest — that looks random but is deterministic: the same input always produces the same output. Change a single bit and the digest changes completely, a property called the avalanche effect. Unlike Base64 encoding, hashing is a one-way operation. There is no key, no secret, and no way to reverse the process to recover the original input.

Hashes serve two purposes: integrity verification (confirming a file or message has not been altered) and commitment (proving you knew a value without revealing it). Passwords are stored as hashes so that a database leak does not expose the original credentials; downloads are published alongside checksums so you can verify the file arrived intact.

SHA-256 vs MD5 — Which Should You Use?

MD5 was designed in 1991 and produces a 128-bit (32-character hex) digest. It is fast and compact, but it is cryptographically broken — researchers demonstrated practical collision attacks in 2004, and in 2012 the Flame malware exploited an MD5 collision in Windows Update certificates. MD5 should never be used for security. It is still acceptable as a non-cryptographic checksum where collision resistance does not matter: verifying a download, deduplicating files, or building a cache key.

SHA-256 is part of the SHA-2 family, published by NIST in 2001. It produces a 256-bit (64-character hex) digest. No practical collision or preimage attacks exist. It is the default choice for anything security-related: certificate signatures (TLS certificates use SHA-256), blockchain proof of work (Bitcoin), git commit identifiers (since Git 2.29), content-addressable storage, and HMAC-based authentication such as the signatures in JWTs signed with HS256.

Hash Algorithm Comparison

AlgorithmDigest sizeHex charsStatusUse case
MD5128 bits32Broken — collisions practicalNon-security checksums only
SHA-1160 bits40Deprecated — collision demonstrated (SHAttered, 2017)Legacy systems, git (transitioning away)
SHA-256256 bits64SecureGeneral purpose, TLS, blockchain, HMAC
SHA-384384 bits96SecureTLS cipher suites requiring >256-bit security
SHA-512512 bits128SecureLarger margin, slightly faster on 64-bit CPUs

When to Use Each Algorithm

How Hashing Works, Step by Step

Every hash function follows the same pattern. The input is padded to a multiple of the block size (512 bits for SHA-256, 512 bits for MD5). Padding always includes a 1 bit, then zeros, then the original message length. The padded message is split into blocks, and each block is processed through a compression function that mixes it with the running state. The final state is the digest.

The compression function is where the algorithms diverge. MD5 uses four rounds of 16 operations each, with bitwise functions and precomputed sine-table constants. SHA-256 uses 64 rounds with a more complex mixing schedule and different constants derived from the first 64 primes. The additional rounds and wider state are what give SHA-256 its collision resistance.

How to Hash in Every Language

JavaScript / Node.js

// Browser (SHA-256)
const data = new TextEncoder().encode("hello");
const hash = await crypto.subtle.digest("SHA-256", data);
const hex = [...new Uint8Array(hash)]
  .map(b => b.toString(16).padStart(2, "0")).join("");

// Node.js
const { createHash } = require("crypto");
const hex = createHash("sha256").update("hello").digest("hex");

Python

import hashlib
hashlib.sha256(b"hello").hexdigest()
hashlib.md5(b"hello").hexdigest()

Java

import java.security.MessageDigest;
byte[] hash = MessageDigest.getInstance("SHA-256")
    .digest("hello".getBytes("UTF-8"));
StringBuilder sb = new StringBuilder();
for (byte b : hash) sb.append(String.format("%02x", b));

Bash / Command Line

# SHA-256
echo -n "hello" | sha256sum
# MD5
echo -n "hello" | md5sum
# File hash
sha256sum myfile.tar.gz

Go

import (
    "crypto/sha256"
    "fmt"
)
h := sha256.Sum256([]byte("hello"))
fmt.Printf("%x\n", h)

Verifying File Integrity with Checksums

When a project publishes a download alongside a .sha256 file, the workflow is straightforward. Download the file, hash it locally, and compare the digests. If they match, the file arrived intact. If they differ, the download was corrupted or tampered with.

# Download and verify
curl -O https://example.com/release.tar.gz
curl -O https://example.com/release.tar.gz.sha256
sha256sum -c release.tar.gz.sha256

This tool performs the same operation in your browser — drop the file onto the drop zone, select SHA-256, and compare the output to the published digest. Nothing is uploaded, so verifying a confidential binary does not leak it.

Common Hashing Mistakes

Hash Lengths at a Glance

The digest is always the same length regardless of input size. An empty string and a gigabyte file produce the same number of hex characters.

AlgorithmHex outputExample (hash of "hello")
MD532 chars5d41402abc4b2a76b9719d911017c592
SHA-140 charsaaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d
SHA-25664 chars2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
SHA-38496 chars59e1748777448c69de6b800d7a33bbfb9ff1b463e44354c3553bcdb9c666fa90125a3c79f90397bdf5f6a13de828684f
SHA-512128 chars9b71d224bd62f3785d96d46ad3ea3d73319bfbc2890caadae2dff72519673ca72323c3d99ba5c11d7c7acc6e14b8c5da0c4663475c2e5c3adef46f73bcdec043

Subresource Integrity (SRI)

When you load a script from a CDN, the CDN could theoretically serve malicious code. Subresource Integrity lets browsers verify a fetched resource against a hash you commit to in your HTML:

<script src="https://cdn.example.com/lib.js"
  integrity="sha384-oqVuAfXRKap7fdg..."
  crossorigin="anonymous"></script>

The browser hashes the downloaded file and refuses to execute it if the digest does not match. SRI uses SHA-256, SHA-384, or SHA-512 — never MD5 or SHA-1. The hash is Base64-encoded (not hex), so if you need to convert between formats, our Base64 encoder handles that.

Hashing in Cron Jobs and Automation

Scheduled scripts that fetch remote data often need to detect whether anything changed since the last run. Hashing the fetched content and comparing it to the stored hash from the previous run is cheaper and more reliable than tracking modification timestamps, which many APIs do not provide. If you are writing those schedules, our cron expression generator shows the next run times so you can verify the interval before deployment.

Frequently Asked Questions

Is my data sent to a server?
No. All hashing runs in your browser using the Web Crypto API (for SHA) and a pure JavaScript implementation (for MD5). Nothing is transmitted, logged, or stored.
Can I reverse a hash to get the original text?
No. A cryptographic hash is a one-way function. There is no mathematical inverse. The only way to find an input that produces a given hash is to try candidates until one matches — which is computationally infeasible for a strong hash like SHA-256 with sufficient input entropy.
Why is MD5 still offered if it is broken?
MD5 is broken for collision resistance, meaning an attacker can craft two different inputs with the same hash. It is still fine as a non-cryptographic checksum — verifying that a download was not corrupted in transit, deduplicating files, or building cache keys. It should never be used where an adversary controls the input.
Is SHA-256 the same as SHA-2?
SHA-2 is a family of algorithms: SHA-224, SHA-256, SHA-384, and SHA-512. SHA-256 is the most widely used member. When documentation says "SHA-2", it almost always means SHA-256 specifically.
Should I use SHA-256 to hash passwords?
No. SHA-256 is designed to be fast, which is exactly what you do not want for passwords. Use bcrypt, scrypt, or Argon2id — algorithms that are deliberately slow and memory-intensive to resist brute-force and GPU attacks.
Why does my hash differ from another tool's output?
Almost always an encoding difference. Check whether both tools encode the input as UTF-8 bytes before hashing, and whether the other tool appends a trailing newline (command-line echo without -n does). Case differences in the hex output (uppercase vs lowercase) do not mean the hashes differ — the underlying bytes are the same.