Skip to content
Local Only Dev Tools
4 min read

SHA-256 vs SHA-512

Differences, performance and security considerations for common hash algorithms.

Quick answer

Both are SHA-2 hashes. SHA-256 produces 32 bytes and SHA-512 produces 64 bytes; follow the protocol you are implementing.

Digest size

SHA-256 produces a 256-bit digest; SHA-512 produces a 512-bit digest. Both are members of the SHA-2 family and are considered secure for general use.

Performance

On 64-bit CPUs SHA-512 is often faster than SHA-256 for large inputs, while SHA-256 is more common in protocols and hardware.

Which to choose

Follow the requirements of the protocol you are implementing. For new applications either is acceptable; truncation and poor key handling are far bigger risks than the choice of digest.

Common mistakes

  • •Choosing a hash by name alone
  • •Truncating digests without a specification
  • •Using a bare hash for passwords

When to use this

  • •File integrity checks
  • •Digital signatures
  • •API request signing

Try it yourself

Compute SHA-1, SHA-256, SHA-384 and SHA-512 hashes of any text locally. Runs locally in your browser.

Open Hash Generator