PHP Hash Algorithm Benchmark

Published On21 Nov 2020

PHP Hash Benchmark

PHP supports a wide range of hashing functions, and from PHP 7.4, the Hash extension is bundled with PHP core.

Not all hash algorithms are equal. Among the list of hash algorithms included in PHP, it includes ones that have a lot of collisions, ones that are easy to break if used in cryptographic applications, and algorithms with various hash lengths.

PHP 8.1 adds support for MurmurHash3 and xxHash that are quite fast compared to other hashing algorithms including SHA3, MD5, and SHA2. In fact, the new xxh3 is the fastest hashing algorithm supported in PHP to date.

This benchmark was done on 100 MB of random data, with each hashing algorithm hashing the same random data blob, averaged from 5 runs, on an isolated Ubuntu 20.10 instance running on an AMD 4800H CPU, that has built-in CPU instructions for some hashing algorithms.


Algorithm name Output width (bits) Speed (GB/s)
xxh3 64 15.19
xxh128 128 14.78
crc32c 32 14.12
xxh64 64 13.32
crc32 32 13.19
crc32b 32 12.71
murmur3f 128 8.87
xxh32 32 7.47
murmur3c 128 6.20
murmur3a 32 3.98
adler32 32 2.00
md4 128 1.12
fnv1a64 64 1.01
fnv132 32 1.00
fnv164 64 1.00
fnv1a32 32 0.98
joaat 32 0.80
md5 128 0.77
tiger128,3 128 0.75
tiger160,3 160 0.75
tiger192,3 192 0.74
sha1 160 0.70
tiger160,4 160 0.57
tiger128,4 128 0.56
tiger192,4 192 0.56
ripemd128 128 0.49
ripemd256 256 0.46
sha3-224 224 0.43
sha3-256 256 0.41
sha384 384 0.38
sha512/224 224 0.38
sha512/256 256 0.38
sha512 512 0.38
ripemd320 320 0.33
ripemd160 160 0.32
sha3-384 384 0.31
haval128,3 128 0.30
haval160,3 160 0.30
haval192,3 192 0.30
haval224,3 224 0.30
haval256,3 256 0.30
sha224 224 0.25
sha256 256 0.25
sha3-512 512 0.22
haval128,4 128 0.22
haval160,4 160 0.22
haval192,4 192 0.22
haval224,4 224 0.22
haval256,4 256 0.22
haval128,5 128 0.17
haval160,5 160 0.17
haval192,5 192 0.17
haval224,5 224 0.17
haval256,5 256 0.17
whirlpool 512 0.16
gost 256 0.07
gost-crypto 256 0.07
snefru 256 0.03
snefru256 256 0.03
md2 128 0.01

The Output width (bits) column contains the number of bites the hashing algorithm produces. This is not necessarily the length when encoded. For example, when encoded to Hexadecimal, the output length will fourth of the Output width (bits) column value, because each hexadecimal character encodes four bits.

Hash Benchmark

PHP Hash Benchmark - Chart

Recent Articles on PHP.Watch

All ArticlesFeed 
PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian

A guide for Debian and Ubuntu on how to install PHP 8.4 on a new server or how to upgrade an existing PHP setup to PHP 8.4.
How to fix `mysql_native_password` not loaded errors on MySQL 8.4

How to fix mysql_native_password not loaded errors on MySQL 8.4

How to fix the SQLSTATE[HY000] [1524] Plugin 'mysql_native_password' is not loaded errors caused in MySQL 8.4 no longer enabling the mysql_native_password plugin by default.
How to fix PHP Curl HTTPS Certificate Authority issues on Windows

How to fix PHP Curl HTTPS Certificate Authority issues on Windows

On Windows, HTTPS requests made with the Curl extension can fail because Curl has no root certificate list to validate the server certificates. This article discusses the secure and effective solutions, and highlights bad advice that can leave PHP applications insecure.
Subscribe to PHP.Watch newsletter for monthly updates

You will receive an email on last Wednesday of every month and on major PHP releases with new articles related to PHP, upcoming changes, new features and what's changing in the language. No marketing emails, no selling of your contacts, no click-tracking, and one-click instant unsubscribe from any email you receive.

Support PHP.Watch — If you find the articles, version information, Codex, and other PHP.Watch contributions useful, consider supporting through GitHub Sponsors. Your sponsorship helps dedicate more time to creating valuable content and improving the PHP community. Together, we can keep the momentum going — thank you for your support!

Thanks to the highest tier sponsor: @TomasVotruba for your generous support to keep PHP.Watch moving 💜