3v4l.org

run code in 300+ PHP versions simultaneously
<?php function pbkdf2( $algorithm = 'sha512', $password, $salt, $count = 2048, $key_length = 512, $raw_output = false ){ if($count <= 0 || $key_length <= 0) { $count = 2048; $key_length = 512; } $hash_length = strlen(hash($algorithm, "", true)); $block_count = ceil($key_length / $hash_length); $output = ""; for($i = 1; $i <= $block_count; $i++) { $last = $salt . pack("N", $i); $last = $xorsum = hash_hmac($algorithm, $last, $password, true); for ($j = 1; $j < $count; $j++) { $xorsum ^= ($last = hash_hmac($algorithm, $last, $password, true)); } $output .= $xorsum; } if($raw_output) { return substr($output, 0, $key_length); } else { return bin2hex(substr($output, 0, $key_length)); } } function generate_salt(){ $random = file_get_contents( '/dev/urandom', false, null, 0, 256 ); return bin2hex( $random ); } function get_hash( $plain_text, $salt ){ if( !isset($plain_text) || !isset($salt) ){ return false; } if( gettype($salt) == "string" ){ $salt = array( $salt, $salt ); } $iterations = 1024; if( !function_exists("hash_pbkdf2") ){ $hash = pbkdf2( "whirlpool", $plain_text, $salt[0], $iterations, 512, true ); $hash = pbkdf2( "sha512", $hash, $salt[1], $iterations, 512 ); } else { $hash = hash_pbkdf2( "whirlpool", $plain_text, $salt[0], $iterations, 512, true ); $hash = hash_pbkdf2( "sha512", $hash, $salt[1], $iterations, 512 ); } return $hash; } function test(){ $salt = array( 0 => generate_salt(), 1 => generate_salt() ); $salt = array( 0 => '5162e9d43703517e8efa9c0ff835e6d49914e60ae567574466e21bdbb6d6e647d58e468c3b5ff1b4b5bf667ce7d9896d0a8535bb9e862c65f998ba45fafa5fee1eef524873f3daf5405a36a471dc87803ac25df9d05463649e80941982c97315fb94b0d8d812420e1433fa45b75cbfba70723d5ad7fefe10a4e4d6e4759bacaa93903947e1f9157b204fbd17c489cc5edeb02f35301b45a4e3f0097aadf74e7bbdc25050c685e236fd90125e236e2eb349ec1bf2a7a33f3e6e1555b8658c0fcb155220b14cf03f420a7fda1012b089238c2c6226bf0d5c38742df8853caccd6f23baa0b2430731d4ba9c52d5b1d7e07622524969399971ad42a4af1195b14e7b', 1 => '81c36d5f5612aeae6b5d5595f0ed1541f6f732f1512695baceb514e1964f9a0551d902945df52c81a77f3b66936040be1eb723e571e5d1de7769fe016ccfa7b9468e1d912b17d608f052a3ae834254445be575c47f75f88464116698dba29694e5da8082c1e97430ab46cf7d5be5d0e2c4f94db93eb8c7bfdd5bb84d68d4685a31f6fb06e2408a268a651395b9faef509acbfdbb9d32fd0ffe5b8b7f7f71e72c825fe2e516e3be082041807978bc17a48f2ed53ed00a8533cbaa90b49b6ebda6028406a1845ada1ac77ca7433ee27449913afd82726d47c96237b9f5059404033e1bc62a60ffcd9d174f6ca49b6b07a0ae3042bc1ba06ad56e85466cf4cc6025' ); $plain_text = "mysupersecurepassword"; echo "start \n"; $time = time(); $result = get_hash( $plain_text, $salt ); echo $result; echo "\ntime: ". ( time() - $time ); } test(); ?>

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
7.3.120.0100.08515.20
7.3.110.0100.08514.92
7.3.100.0000.05314.55
7.3.90.0070.04915.00
7.3.80.0030.04514.82
7.3.70.0100.04314.82
7.3.60.0030.04915.04
7.3.50.0100.04215.07
7.3.40.0070.05115.04
7.3.30.0000.05414.95
7.3.20.0100.04016.85
7.3.10.0060.04416.70
7.3.00.0030.05516.73
7.2.240.0100.08515.15
7.2.230.0070.05415.41
7.2.220.0100.06115.03
7.2.210.0070.04515.31
7.2.200.0030.04814.97
7.2.190.0030.05215.17
7.2.180.0070.04315.32
7.2.170.0030.04815.30
7.2.160.0030.05215.06
7.2.150.0060.05116.66
7.2.140.0100.03917.09
7.2.130.0020.05016.89
7.2.120.0090.04316.86
7.2.110.0090.05017.10
7.2.100.0050.04717.01
7.2.90.0050.05017.10
7.2.80.0020.05416.86
7.2.70.0050.04916.91
7.2.60.0060.04716.95
7.2.50.0060.04916.88
7.2.40.0070.04516.98
7.2.30.0020.05117.11
7.2.20.0050.04916.95
7.2.10.0050.05016.88
7.2.00.0020.04917.08
7.1.330.0060.05215.78
7.1.320.0030.04716.05
7.1.310.0070.04316.07
7.1.300.0070.07615.66
7.1.290.0030.04615.58
7.1.280.0000.05015.88
7.1.270.0030.04815.68
7.1.260.0030.04815.80
7.1.250.0120.04415.87
7.1.200.0000.05316.01
7.1.70.0000.04617.23
7.1.60.0070.09319.43
7.1.50.0070.09316.70
7.1.00.0070.13722.45
7.0.200.0000.04416.82
7.0.90.0030.13321.70
7.0.80.0030.08721.96
7.0.70.0130.10321.82
7.0.60.0000.14721.86
7.0.50.0100.12322.09
7.0.40.0100.09720.10
7.0.30.0030.11020.08
7.0.20.0030.08720.00
7.0.10.0100.12020.03
7.0.00.0130.13720.14
5.6.280.0100.06320.94
5.6.240.0070.14320.65
5.6.230.0170.12020.61
5.6.220.0100.09720.50
5.6.210.0100.08720.67
5.6.200.0070.12021.06
5.6.190.0070.07721.15
5.6.180.0130.10721.04
5.6.170.0070.12321.19
5.6.160.0100.09721.13
5.6.150.0200.12321.00
5.6.140.0030.11320.93
5.6.130.0070.13321.13
5.6.120.0130.10321.08
5.6.110.0070.08720.97
5.6.100.0030.11720.94
5.6.90.0100.13321.05
5.6.80.0070.12320.49
5.6.70.0100.14020.44
5.6.60.0130.12020.39
5.6.50.0130.12720.48
5.6.40.0100.13020.41
5.6.30.0100.13320.48
5.6.20.0100.13320.43
5.6.10.0130.13020.42
5.6.00.0070.13020.36
5.5.380.0070.10320.46
5.5.370.0100.07720.44
5.5.360.0030.13320.55
5.5.350.0000.09320.44
5.5.340.0070.13320.92
5.5.330.0100.14320.80
5.5.320.0070.12020.88
5.5.310.0100.08020.94
5.5.300.0030.14320.79
5.5.290.0030.11020.90
5.5.280.0000.14020.79
5.5.270.0100.13320.88
5.5.260.0070.12720.89
5.5.250.0030.08020.75
5.5.240.0070.12720.21
5.5.230.0100.13320.32
5.5.220.0030.07720.12
5.5.210.0070.07720.11
5.5.200.0030.13020.29
5.5.190.0130.13320.23
5.5.180.0100.11720.13
5.5.160.0030.17720.29
5.5.150.0030.08320.29
5.5.140.0100.11020.17
5.5.130.0070.11320.28
5.5.120.0100.12720.19
5.5.110.0130.09320.29
5.5.100.0070.12720.10
5.5.90.0100.13719.96
5.5.80.0070.13720.09
5.5.70.0130.11720.10
5.5.60.0100.07020.11
5.5.50.0000.08020.11
5.5.40.0000.08020.10
5.5.30.0030.07720.16
5.5.20.0000.06720.06
5.5.10.0030.07720.09
5.5.00.0000.08020.09
5.4.450.0070.17319.47
5.4.440.0070.17019.28
5.4.430.0100.18019.46
5.4.420.0100.16719.46
5.4.410.0070.18319.14
5.4.400.0030.18319.14
5.4.390.0000.16319.15
5.4.380.0030.16718.95
5.4.370.0100.13019.13
5.4.360.0030.13019.16
5.4.350.0070.17719.14
5.4.340.0100.17319.18
5.4.320.0070.17719.03
5.4.310.0000.14019.12
5.4.300.0100.15718.96
5.4.290.0100.16318.86
5.4.280.0000.18318.95
5.4.270.0070.10718.90
5.4.260.0070.18018.85
5.4.250.0030.14719.20
5.4.240.0030.12018.89
5.4.230.0000.11018.87
5.4.220.0030.12319.13
5.4.210.0030.11719.12
5.4.200.0030.09019.04
5.4.190.0030.10718.94
5.4.180.0070.10319.20
5.4.170.0030.11019.11
5.4.160.0000.10718.83
5.4.150.0000.11319.07
5.4.140.0030.10716.50
5.4.130.0030.09316.54
5.4.120.0000.09016.47
5.4.110.0000.11016.55
5.4.100.0000.11716.53
5.4.90.0000.09016.52
5.4.80.0100.11316.52
5.4.70.0130.07716.47
5.4.60.0070.08316.34
5.4.50.0000.11016.39
5.4.40.0000.11016.48
5.4.30.0000.09316.31
5.4.20.0030.09716.30
5.4.10.0070.10316.41
5.4.00.0000.11715.87

preferences:
35.58 ms | 401 KiB | 5 Q