DevFormatter

Hash Generator

Input
Hashes
 

Hash Generator is a free browser-based tool that computes MD5, SHA-1, SHA-256, SHA-384, and SHA-512 cryptographic hashes from any text input. All hashing runs in the browser using the Web Crypto API (SHA variants) and CryptoJS (MD5) — no input is ever sent to a server. Use it to verify file integrity, generate checksums, test HMAC inputs, or explore hash algorithm differences.

Hash Generator

How it works

Last updated: November 2026

A hash function takes an input of any length and produces a fixed-size string of hexadecimal characters — the hash or digest. The same input always produces the same output, but even a single character change produces a completely different hash.

This tool computes MD5, SHA-1, SHA-256, SHA-384 and SHA-512 entirely in your browser using the Web Crypto API (SHA variants) and CryptoJS (MD5). Nothing is sent to a server.

Algorithm Reference

Algorithm Output length Use case Security
MD5128-bit / 32 hex charsChecksums, non-security deduplicationBroken — collisions known
SHA-1160-bit / 40 hex charsLegacy systems, Git object IDsDeprecated — avoid new use
SHA-256256-bit / 64 hex charsFile integrity, HMAC, JWT signingSecure — recommended
SHA-384384-bit / 96 hex charsTLS certificates, SRI integritySecure
SHA-512512-bit / 128 hex charsPassword hashing pipelines, archivesSecure — strongest here

Tips & Tricks

Trailing newlines change the hash

Most editors add a newline at end of file. echo "hello" includes a newline; echo -n "hello" does not. Always use -n when verifying hashes.

SHA-256 is the safe default

MD5 and SHA-1 have known collision attacks. For any new system — file integrity, API signatures, HMAC — use SHA-256 or higher.

Don't hash passwords directly

SHA-256 is fast — that's bad for passwords. Use bcrypt, scrypt, or Argon2 which are intentionally slow and salted.

SRI uses SHA-384 or SHA-512

Subresource Integrity (SRI) hashes in <script integrity="…"> tags use base64-encoded SHA-384 or SHA-512, not hex.

Git uses SHA-1 (soon SHA-256)

Git object IDs are SHA-1 hashes. Git 2.29+ supports SHA-256 repositories via --object-format=sha256, though SHA-1 is still the default.

Encoding matters: hex vs base64

The hash value is raw bytes. Hex uses 2 chars per byte; base64 uses ~1.33 chars per byte. JWT and SRI use base64; most CLI tools output hex.

Code Examples

Node.js

const crypto = require('crypto');
const input = 'hello world';

console.log('MD5:    ', crypto.createHash('md5').update(input).digest('hex'));
console.log('SHA-1:  ', crypto.createHash('sha1').update(input).digest('hex'));
console.log('SHA-256:', crypto.createHash('sha256').update(input).digest('hex'));

Python

import hashlib

text = 'hello world'
print('MD5:    ', hashlib.md5(text.encode()).hexdigest())
print('SHA-1:  ', hashlib.sha1(text.encode()).hexdigest())
print('SHA-256:', hashlib.sha256(text.encode()).hexdigest())

CLI (macOS / Linux)

# macOS / Linux
echo -n "hello world" | md5sum
echo -n "hello world" | sha1sum
echo -n "hello world" | sha256sum

# macOS (built-in)
echo -n "hello world" | openssl dgst -md5
echo -n "hello world" | openssl dgst -sha256

FAQ

What is a hash function?

A hash function maps an input of arbitrary length to a fixed-size output called a digest. The same input always produces the same hash, but a tiny change in input produces a completely different hash — this property is called the avalanche effect. Hash functions are one-way: you cannot reconstruct the original input from the hash value alone. For example, the SHA-256 hash of "hello" is always 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824, regardless of which system computes it. A good cryptographic hash function also exhibits collision resistance — it is computationally infeasible to find two different inputs that produce the same hash. This combination of determinism, one-way computation, and collision resistance makes hash functions fundamental to digital signatures, password storage, file integrity verification, and blockchain systems. The Web Crypto API (crypto.subtle.digest) in modern browsers computes SHA variants natively and efficiently.

What is the difference between MD5 and SHA-256?

MD5 produces a 128-bit (32-character hex) digest and is fast but cryptographically broken — researchers have demonstrated practical collision attacks where two different inputs produce the same MD5 hash in seconds on consumer hardware, using techniques first published by Wang and Yu in 2004. SHA-256 produces a 256-bit (64-character hex) digest and is part of the SHA-2 family standardised by NIST in 2001. No practical collision attacks on SHA-256 are known, and its security margin is considered very large. Performance-wise, MD5 is faster than SHA-256 on most hardware, but that speed advantage is irrelevant for most applications. The correct rule is: use SHA-256 (or SHA-512) for any security-sensitive application including file integrity, HMAC, JWT signing, and password-hashing pipelines. MD5 is acceptable only for non-security uses such as deduplication keys in a database or legacy checksums where an attacker cannot craft collisions.

Is MD5 safe to use?

MD5 is not safe for any security-sensitive purpose. Collisions — two different inputs that produce the same hash — can be computed in seconds on modern hardware using the differential path technique first demonstrated by Xiaoyun Wang in 2004 and refined by Marc Stevens in later work. Known real-world attacks include the Flame malware (2012), which forged a valid Microsoft code-signing certificate using an MD5 collision. For storing passwords, MD5 is especially dangerous because it is fast: a modern GPU can compute billions of MD5 hashes per second, making brute-force and rainbow-table attacks trivial. MD5 remains acceptable for non-security applications where an attacker cannot craft input — such as detecting accidental file corruption, deduplication in a content-addressed store, or generating cache keys from known-safe inputs. For anything security-related, use SHA-256 or higher, and for passwords use bcrypt, scrypt, or Argon2.

Can I reverse a hash to get the original input?

No. Cryptographic hash functions are designed to be computationally one-way (pre-image resistant): given a hash output, there is no efficient algorithm to find an input that produces it. For a 256-bit hash like SHA-256, a brute-force search would require 2^256 operations — far beyond any feasible computation. However, for small or predictable inputs like short passwords or common words, an attacker can precompute hashes for all likely inputs (a rainbow table attack) and look up the hash to find the original value. For example, the MD5 of "password" is 5f4dcc3b5aa765d61d8327deb882cf99 — this appears in every rainbow table. This is why passwords must never be hashed with a plain cryptographic hash function. Instead, use bcrypt (via the bcrypt npm package or Python's bcrypt library), scrypt, or Argon2 — all of which add a random salt (preventing rainbow tables) and are intentionally slow to compute (limiting brute-force speed).

Why does my hash differ from another tool?

The most common causes of hash mismatches are: (1) Trailing newline — the shell command echo "hello" appends a newline character (\n), producing a different hash than echo -n "hello" which does not. Use echo -n consistently when verifying hashes on the command line. (2) Character encoding — the string "café" encodes to different bytes in UTF-8 (5 bytes: 63 61 66 C3 A9) versus Latin-1/ISO-8859-1 (4 bytes: 63 61 66 E9), producing completely different hashes. This tool encodes all text as UTF-8 using the Web Crypto API's TextEncoder, which is the most common encoding in modern applications. (3) Whitespace differences — leading or trailing spaces, Windows line endings (CRLF vs LF), or BOM characters in the input produce different byte sequences. (4) Hex case — some tools output lowercase hex (e.g. 2cf24d...) and others uppercase (2CF24D...); they represent the same hash value. Always compare hashes in the same case and confirm the encoding before concluding a mismatch indicates corruption.

What is SHA-2 vs SHA-3?

SHA-2 is a family of hash functions — SHA-224, SHA-256, SHA-384, SHA-512, SHA-512/224, and SHA-512/256 — standardised by NIST in 2001. All SHA-2 variants share the same underlying Merkle–Damgård construction. SHA-3 (Keccak) uses a completely different sponge construction and was standardised by NIST in 2015 (FIPS 202) as an independent backup in case a structural weakness was found in SHA-2's design. Both SHA-2 and SHA-3 are currently considered cryptographically secure — no practical attacks are known against either family. SHA-256 from SHA-2 remains the dominant choice in production systems because it has been deployed and vetted for over 20 years: TLS/HTTPS certificate signatures, Bitcoin's proof-of-work, JWT signing, AWS API request signing, and Docker image digests all use SHA-256. SHA-3 sees growing use in newer cryptographic protocols and hardware security modules (HSMs) that explicitly require a Keccak-based algorithm. This tool provides SHA-2 variants (SHA-256, SHA-384, SHA-512) which cover the vast majority of practical use cases.

What is HMAC?

HMAC (Hash-based Message Authentication Code, defined in RFC 2104) combines a cryptographic hash function with a secret key to produce a fixed-size authentication code. Unlike a plain hash, an HMAC proves both integrity (the message has not been modified) and authenticity (only someone who knows the secret key could have produced it). The formula is HMAC(key, message) = H((key XOR opad) || H((key XOR ipad) || message)), where H is the underlying hash function. HMAC-SHA256 (using SHA-256 as the hash function) is the algorithm behind JWT HS256 signatures, AWS Signature Version 4 request signing, GitHub webhook signature verification (X-Hub-Signature-256 header), Stripe webhook verification, and many API authentication schemes. In Node.js: crypto.createHmac('sha256', key).update(message).digest('hex'). In Python: hmac.new(key.encode(), message.encode(), hashlib.sha256).hexdigest(). The key must be kept secret; a plain SHA-256 hash without a key provides no authentication guarantee.

What is a checksum?

A checksum is a hash value computed from a file and published alongside it, so that anyone who downloads the file can verify it was not corrupted or tampered with in transit. Linux distributions such as Ubuntu, Debian, and Fedora publish SHA-256 checksums for their ISO images; after downloading, you run sha256sum ubuntu.iso on Linux/macOS (or Get-FileHash ubuntu.iso on Windows PowerShell) and compare the output to the published value. A mismatch means the file is corrupt or has been modified — which could indicate either accidental corruption during transfer or a man-in-the-middle attack substituting a malicious file. Package managers also use checksums internally: npm's package-lock.json stores SHA-512 integrity hashes for every package, and pip verifies package hashes against PyPI's recorded values. Docker image digests are SHA-256 hashes of the image manifest, allowing you to pin to an exact image version with docker pull image@sha256:...

What is the output length of each algorithm?

Each hash algorithm produces a fixed-size output regardless of input length: MD5 produces 128 bits (32 lowercase hex characters), SHA-1 produces 160 bits (40 hex characters), SHA-256 produces 256 bits (64 hex characters), SHA-384 produces 384 bits (96 hex characters), and SHA-512 produces 512 bits (128 hex characters). All outputs here are expressed as lowercase hexadecimal. When the hash is base64-encoded instead of hex — which is common in JWT (HS256), SRI integrity attributes, and some API signatures — the lengths are shorter: a 256-bit value becomes 44 base64 characters (43 non-padding + one =), and a 512-bit value becomes 88 base64 characters. The hex representation is 2 characters per byte; base64 is approximately 1.33 characters per byte, so base64 is about 33% shorter than hex for the same data. Some systems use URL-safe base64 (- and _ instead of + and /) and omit the = padding.

Does this tool work offline?

Yes. All hashing runs entirely in the browser using the Web Crypto API (for SHA-1, SHA-256, SHA-384, and SHA-512) and the CryptoJS library (for MD5). No network requests are made when you generate a hash — the computation is performed locally by your browser's JavaScript engine. Once the page has loaded (which requires an initial network request), you can disconnect from the internet and the tool continues to work correctly for as long as the page remains open. The Web Crypto API (crypto.subtle.digest) is available in all modern browsers including Chrome 37+, Firefox 34+, Safari 11+, and Edge 12+, and in Node.js (via the global crypto object in v19+). The absence of server-side processing also means the tool has no downtime, no rate limits, and no usage restrictions — it is as reliable as your local machine.

Is my input sent to a server?

No. Text you enter is processed entirely in your browser using the Web Crypto API and CryptoJS — nothing is transmitted to DevFormatter's servers or any other server. This is especially important for hash generators because developers often hash sensitive values for comparison or debugging: passwords during authentication troubleshooting, API secret keys, private tokens, or confidential configuration values. Sending those to a third-party server would be a significant security risk. You can confirm the tool's privacy by opening the Network tab in your browser's DevTools — no outbound requests are made when you type or generate a hash. The tool is stateless: it does not use localStorage for the input text, does not set cookies related to your input, and does not log or store anything you hash. No account, sign-up, or login is required.

What is SHA-256 used for in practice?

SHA-256 is the most widely deployed cryptographic hash function in production systems today. It is used in: TLS/HTTPS certificate signatures (every HTTPS connection relies on SHA-256 in its certificate chain), Bitcoin's double-SHA-256 proof-of-work algorithm for block mining, JWT HS256 and RS256 token signatures, Amazon S3 and AWS Signature Version 4 API request signing (the HMAC-SHA256 of the canonical request), Docker image layer digests (docker pull uses SHA-256 to identify and verify images), npm and yarn package integrity verification (the integrity field in package-lock.json is a SHA-512 or SHA-256 hash), pip package verification against PyPI's recorded hashes, file integrity checksums distributed with Linux ISO images, and Subresource Integrity (SRI) hashes in HTML script and link tags. Its combination of 256-bit security, standardisation by NIST (FIPS 180-4), and hardware acceleration in modern CPUs (via the SHA-NI instruction set on x86 and ARMv8 Cryptography Extensions) makes SHA-256 the safe default for virtually all new hash applications.

Related Tools