Original Research

Hash Function Benchmark

By Michael Lip · Published April 11, 2026 · Data source: Node.js crypto benchmark · Last updated:
5
Algorithms Tested
2,713
Peak MB/s
4.5x
SHA-256 vs MD5
20
Benchmark Configs

Which hash function is fastest in practice? We ran a real Node.js benchmark using the crypto module, hashing 1,000 iterations at each of four input sizes (1KB, 10KB, 100KB, 1MB) across five algorithms. The surprising result: SHA-256 is 4.5x faster than MD5 on modern hardware thanks to CPU-level SHA acceleration (SHA-NI instructions).

All benchmarks were run on April 11, 2026 using Node.js with the native crypto.createHash() API, which delegates to OpenSSL and takes advantage of hardware acceleration when available.

Benchmark Results by Input Size

Input Size Algorithm Avg Time (ms) Throughput (MB/s) Relative Speed
1 KBSHA-3840.0011928.7Fastest
1 KBSHA-10.0012813.41.14x
1 KBSHA-2560.0014689.41.35x
1 KBSHA-5120.0018532.11.75x
1 KBMD50.0022445.12.09x
10 KBSHA-10.00392,499.7Fastest
10 KBSHA-2560.00392,489.01.00x
10 KBSHA-3840.00651,504.51.66x
10 KBSHA-5120.00661,485.41.68x
10 KBMD50.0171570.44.38x
100 KBSHA-10.03632,688.9Fastest
100 KBSHA-2560.03652,676.31.00x
100 KBSHA-3840.06171,581.91.70x
100 KBSHA-5120.06181,581.41.70x
100 KBMD50.1619603.24.46x
1 MBSHA-10.36862,713.2Fastest
1 MBSHA-2560.36912,709.31.00x
1 MBSHA-3840.62961,588.41.71x
1 MBSHA-5120.63081,585.31.71x
1 MBMD51.6528605.04.48x

Algorithm Comparison

Algorithm Output Size Block Size Security Status HW Accel Use Case
SHA-256256 bits (32 bytes)512 bitsSecureSHA-NI (Intel/AMD)General purpose, TLS, Bitcoin
SHA-512512 bits (64 bytes)1024 bitsSecureLimitedHigh-security, large data
SHA-384384 bits (48 bytes)1024 bitsSecureUses SHA-512 internalsTLS 1.2/1.3 cipher suites
SHA-1160 bits (20 bytes)512 bitsBroken (collisions)SHA-NI (Intel/AMD)Legacy only, git (migrating)
MD5128 bits (16 bytes)512 bitsBroken (collisions)NoChecksums only, never security

Methodology

Benchmark details:

  • Runtime — Node.js using native crypto.createHash() which delegates to OpenSSL
  • Iterations — 1,000 iterations per algorithm per input size, reporting average time
  • Timingperformance.now() for sub-millisecond accuracy
  • InputBuffer.alloc(bytes, 'a') for each size (1KB, 10KB, 100KB, 1MB)
  • Output — Full hex digest generated each iteration
  • Hardware — Apple Silicon with hardware SHA acceleration via OpenSSL

Results will vary by CPU architecture. Intel/AMD CPUs with SHA-NI show similar SHA-256 acceleration. Older CPUs without SHA instructions will see MD5 outperform SHA-256.

Frequently Asked Questions

Is SHA-256 faster than MD5?

Yes, on modern hardware with SHA acceleration, SHA-256 is 4.5x faster than MD5. Our benchmark shows SHA-256 at 2,709 MB/s versus MD5 at 605 MB/s for 1MB input. Modern CPUs have dedicated SHA-256 instructions (Intel SHA-NI, ARM SHA2) that MD5 lacks. On older hardware without SHA acceleration, MD5 may still be faster.

Which hash function should I use in 2026?

For security (signatures, integrity): SHA-256 or SHA-512. For passwords: never use SHA/MD5 — use bcrypt, scrypt, or Argon2. For checksums: SHA-256 is recommended since it is faster than MD5 on modern hardware. MD5 and SHA-1 are cryptographically broken and should not be used for any security purpose.

Why is SHA-1 faster than SHA-512 in this benchmark?

SHA-1 operates on 32-bit words with simpler rounds, while SHA-512 uses 64-bit words with higher per-round cost. SHA-1 also benefits from hardware acceleration (SHA-NI on Intel) similar to SHA-256. At large input sizes, SHA-1 and SHA-256 achieve ~2,700 MB/s while SHA-512 peaks at ~1,585 MB/s.

How does input size affect hash function performance?

Throughput increases with input size because per-call overhead is amortized. SHA-256 goes from 689 MB/s at 1KB to 2,709 MB/s at 1MB — a 3.9x improvement. For small inputs like API tokens, per-call overhead dominates; for large files, raw throughput matters.

Is Blake3 faster than SHA-256?

Blake3 is typically 5-10x faster than SHA-256 in software implementations due to its parallelizable tree structure. However, with hardware SHA acceleration (SHA-NI), the gap narrows to 2-3x. Blake3 is not yet available in Node.js crypto natively — you need the blake3 npm package.

Free to use under CC BY 4.0 license. Cite this page when sharing.