πŸ”₯ FireTools

Hashing Algorithms Explained: MD5, SHA-1, SHA-256, SHA-512

By FireTools Team Β· Updated 2026-08-28

Quick Answer

MD5 and SHA-1 are broken and must not be used for security-sensitive purposes. SHA-256 is the current default for integrity checks, signatures, and blockchain. SHA-512 is faster on 64-bit CPUs and used where longer digests are desired. Use our Hash Generator to compute any of these in your browser; use File Hash to verify file integrity.

Introduction

A cryptographic hash function takes an input of arbitrary size and produces a fixed-size digest that is deterministic, fast to compute, infeasible to invert, collision-resistant, and avalanche-sensitive (a one-bit change alters roughly half the output bits). MD5 (128-bit), SHA-1 (160-bit), SHA-256 (256-bit), and SHA-512 (512-bit) are the four most commonly encountered hash functions, but their security properties differ dramatically.

Step by Step

  1. Understand the properties of a hash function

    A good cryptographic hash is deterministic (same input always yields same output), fixed-size output, fast to compute, infeasible to reverse (pre-image resistance), infeasible to find two inputs with the same output (collision resistance), and avalanches (tiny input change flips ~50% of output bits).

  2. Know the digest sizes

    MD5 produces 128 bits (32 hex characters). SHA-1 produces 160 bits (40 hex characters). SHA-256 produces 256 bits (64 hex characters). SHA-512 produces 512 bits (128 hex characters). Longer digests reduce collision probability but increase storage size.

  3. Learn why MD5 and SHA-1 are broken

    Researchers found practical collision attacks against MD5 (2004) and SHA-1 (2017, SHAttered attack). Collisions let an attacker craft two different inputs with the same hash, breaking digital signatures and certificate authorities. Neither should be used for security.

  4. Choose the right algorithm

    For file integrity checks where speed matters more than security, MD5 or SHA-1 are still common. For any security-sensitive use (passwords, signatures, certificates, blockchain), use SHA-256 or SHA-512. For password storage, use a slow KDF like bcrypt, scrypt, or Argon2 β€” never raw SHA-256.

  5. Compute and verify hashes

    Use the Hash Generator to hash text with any algorithm, or File Hash to compute the hash of a local file. Compare the resulting digest against a known-good value to verify integrity β€” a single bit difference means the file was corrupted or tampered with.

Examples

MD5 of 'hello' (128-bit, 32 hex chars)

Input: hello

Output: 5d41402abc4b2a76b9719d911017c592

SHA-256 of 'hello' (256-bit, 64 hex chars)

Input: hello

Output: 2cf24dba5fb0d30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824

Avalanche effect β€” one character change

Input: hello vs Hello

Output: SHA-256('hello') starts 2cf24dba... while SHA-256('Hello') starts 185f8db3... β€” completely different despite one-bit input change

Common Problems

  • Using MD5 or SHA-1 for password hashing: both are fast and broken, making brute-force and rainbow-table attacks trivial. Use bcrypt, scrypt, or Argon2 instead.
  • Confusing hashing with encryption: hashing is one-way and irreversible; encryption is two-way. You cannot 'decrypt' a hash β€” you can only compare hashes.
  • Ignoring length-extension attacks: MD5, SHA-1, SHA-256, and SHA-512 are all vulnerable to length-extension attacks when used as MACs. Use HMAC-SHA256 for message authentication.
  • Comparing hashes with == instead of a constant-time comparison: timing leaks let attackers recover hashes byte by byte. Use a constant-time comparison in security code.

Tips

  • Default to SHA-256 for new systems β€” it is fast, widely supported, and has no practical collision attack as of 2026.
  • For password storage, use bcrypt with a work factor of 12+ (or Argon2id with 64MB memory) β€” never raw SHA-256, which is too fast against GPUs.
  • When verifying file downloads, compare both the algorithm name and the digest β€” a SHA-1 hash is meaningless if the publisher only intended SHA-256.
  • Use our File Hash tool to compute SHA-256 of large files locally without uploading β€” it streams the file through the Web Crypto API.

Related Tools

Related Guides

References