3v4l.org

run code in 300+ PHP versions simultaneously
<?php function test_native() { $st = hrtime(true); $h = hash_pbkdf2('sha256', 'password', 'salt', 100000); $et = hrtime(true); return [$h, $et - $st]; } function test_emulated() { $st = hrtime(true); $K = str_pad('password', 64, "\0"); $K ^= str_repeat("\x36", 64); $ictx = hash_init('sha256'); hash_update($ictx, $K); $K ^= str_repeat("\x6a", 64); $octx = hash_init('sha256'); hash_update($octx, $K); $DK = str_repeat("\0", 32); $prev = "salt\0\0\0\1"; for ($j = 0; $j < 100000; ++$j) { $ctx = hash_copy($ictx); hash_update($ctx, $prev); $temp = hash_final($ctx, true); $ctx = hash_copy($octx); hash_update($ctx, $temp); $prev = hash_final($ctx, true); $DK ^= $prev; } $h = bin2hex($DK); $et = hrtime(true); return [$h, $et - $st]; } $nr = test_native(); $er = test_emulated(); var_dump($nr[0]); var_dump($er[0]); var_dump($nr[1] <= $er[1]);
Output for 8.1.10 - 8.1.33, 8.2.10 - 8.2.29, 8.3.0 - 8.3.28, 8.4.3, 8.4.12 - 8.4.13, 8.5.0 - 8.5.1
string(64) "0394a2ede332c9a13eb82e9b24631604c31df978b4e2f0fbd2c549944f9d79a5" string(64) "0394a2ede332c9a13eb82e9b24631604c31df978b4e2f0fbd2c549944f9d79a5" bool(false)
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.
Output for 8.4.1 - 8.4.2, 8.4.4 - 8.4.11, 8.4.14
string(64) "0394a2ede332c9a13eb82e9b24631604c31df978b4e2f0fbd2c549944f9d79a5" string(64) "0394a2ede332c9a13eb82e9b24631604c31df978b4e2f0fbd2c549944f9d79a5" bool(true)

preferences:
119.53 ms | 409 KiB | 5 Q