Which Ruby hash or message digest algorithm is the speediest in Ruby? My cursory Googling didn’t surface an up-to-date benchmark from anyone else so here are some rough results of my own.

Note: These algorithms are not all equivalent so don’t just blindly pick the fastest one! CRC32, MurmurHash, xxHash, and CityHash are all non-cryptographic.

Update 2024-03-11: Added OpenSSL::Digest for MD5, SHA1, SHA256, SHA512, and SHA3


100,000 iterations of hashing a 1 MiB blob of random data.

Chart of benchmark results

The benchmarks were run on an M1 MacBook Pro.

  • Apple M1 Pro with 10 CPU cores (8 performance and 2 efficiency)
  • macOS Sonoma 14.3.1
  • Ruby 3.3.0
  • OpenSSL 3.2.1

The benchmark source code is available on GitHub.