Which hash to use
| Algorithm | Output | Status |
|---|---|---|
| SHA-256 | 256 bits, 64 hex characters | Secure. The default choice for checksums, signatures and HMAC. |
| SHA-384 / SHA-512 | 384 / 512 bits | Secure. SHA-512 can be faster than SHA-256 on 64-bit CPUs. |
| SHA-1 | 160 bits, 40 hex characters | Broken for collisions since 2017. Only for legacy systems and Git object IDs. |
| MD5 | 128 bits | Broken. Do not use for anything security-related. |
Known value to check against: the SHA-256 of hello is 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824.
Hash in code
// Browser
const buf = await crypto.subtle.digest('SHA-256', new TextEncoder().encode('hello'));
const hex = [...new Uint8Array(buf)].map(b => b.toString(16).padStart(2, '0')).join('');
// Node.js
require('crypto').createHash('sha256').update('hello').digest('hex');
require('crypto').createHmac('sha256', secret).update(body).digest('hex');
# Shell
printf 'hello' | sha256sumFrequently asked questions
Can a SHA-256 hash be reversed?
No. A hash is one-way: there is no key and no way to compute the input from the output. But short or common inputs, such as simple passwords, can be found by trying guesses, which is why passwords need a slow, salted algorithm instead.
Should I hash passwords with SHA-256?
No. SHA-256 is designed to be fast, which makes guessing attacks fast too. Store passwords with a password hashing function such as Argon2id, scrypt or bcrypt, which are deliberately slow and use a unique salt for each password.
Why is there no MD5?
MD5 is broken for security: collisions can be produced in seconds. Browsers’ built-in Web Crypto API does not offer it, and this tool uses only that API. For checksums where security does not matter, SHA-256 is just as practical.
What is HMAC?
HMAC combines a secret key with a hash to produce a signature that proves a message came from someone who knows the key and was not changed. Webhooks from Stripe, GitHub and Shopify are signed with HMAC-SHA256.