Tutorial · Jul 5, 2026 · 4 min read

How to generate MD5, SHA-256, and SHA-512 hashes (without shipping secrets to a server)

A practical hash tutorial: what digests are for, when to use MD5 vs SHA-256 vs SHA-512, and how to hash safely in the browser.


A hash is a fingerprint. You feed in data of any size and get a fixed-length digest back. Change one bit of the input and the digest looks completely different. That property is why hashing shows up in checksums, integrity checks, git objects, password storage pipelines, and CTF puzzles.

You do not need to install a crypto toolkit every time you want a digest. You do need to understand which algorithm you are asking for - and you should not paste secrets into a random website that ships your input to a server.

What a hash is (and is not)

A cryptographic hash function aims for:

  • Determinism - same input, same output
  • Fixed length - MD5 is 32 hex chars, SHA-256 is 64, SHA-512 is 128
  • Avalanche - tiny input changes scramble the digest
  • One-wayness - you should not recover the input from the digest alone

Hashes are not encryption. There is no key and no reversible "decrypt." If someone says they "encrypted the password with MD5," they mean they hashed it - and they probably chose a bad design.

MD5, SHA-256, SHA-512 in practice

MD5 is fast and everywhere in legacy checksums and CTFs. It is broken for collision resistance. Do not use it for security decisions. Fine for "did this non-sensitive blob change?" in low-stakes contexts.

SHA-256 is the default for modern integrity work: release checksums, content addressing, many signatures. Still too fast to use alone for password storage - use bcrypt, Argon2, or scrypt for passwords.

SHA-512 is the longer sibling in the SHA-2 family. Use it when a protocol asks for it or you want a longer digest. On 64-bit machines it can be competitive with SHA-256; on constrained 32-bit environments it is often slower.

For a deeper comparison, read SHA256 vs MD5 vs SHA512.

Common real uses

  1. Verify a download - publisher posts a SHA-256; you hash the file and compare
  2. Detect accidental corruption - same idea inside build pipelines and backups
  3. Cache keys and content addressing - hash the bytes, store by digest
  4. Debugging - confirm two strings that "look the same" actually are
  5. CTF warm-ups - identify algorithm by length, then attack with a wordlist tool

How to hash safely in the browser

Browser crypto (Web Crypto) can compute SHA-256 and friends locally. That means a well-built page never needs to send your string to a backend to get a digest. Prefer client-side tools when the input might be sensitive - API tokens, private notes, unpublished checksums.

Still: anything you type into a webpage can be exfiltrated by a malicious script. Use tools you trust, on HTTPS, and never paste production secrets into a site you found from a random ad.

Hash generation vs hash cracking

GoalWhat you need
Create a digest from known inputA hash generator
Guess plaintext from a digest (authorized / CTF)A cracker + wordlist

Generators and crackers solve opposite problems. Mixing them up is how people accidentally "test" production password hashes in the wrong place. For cracking practice, see HashCrack for CTF beginners - and only attack hashes you are allowed to attack.

Text vs files

Hashing a string in a text box is not the same as hashing a file on disk. Newlines, encoding, and "did the tool hash the filename or the bytes" all cause mismatches. When a publisher posts a checksum for a download, hash the file bytes - not a copy-paste of the filename into a string field.

A simple workflow

  1. Pick the algorithm the publisher or protocol specified
  2. Hash the exact bytes (watch for trailing newlines in text fields)
  3. Compare digests in lowercase hex unless the docs say otherwise
  4. If they differ, check encoding (UTF-8 vs something else) before you panic

Most "hash mismatch" bugs are whitespace or encoding, not crypto failure.

When I need a quick client-side digest without opening a terminal, I use a small browser tool for it.


Blog