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 = 2048; 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.4.10.0000.16915.04
7.4.00.0100.15915.14
7.3.130.0030.16715.16
7.3.120.0070.12214.92
7.3.110.0030.09714.82
7.3.100.0030.09614.98
7.3.90.0020.09115.04
7.3.80.0070.11314.94
7.3.70.0020.10614.96
7.3.60.0050.10515.02
7.3.50.0070.08214.92
7.3.40.0030.09714.92
7.3.30.0070.10114.87
7.3.20.0100.10916.73
7.3.10.0030.09716.65
7.3.00.0040.08816.83
7.2.260.0070.11515.19
7.2.250.0000.12415.18
7.2.240.0080.09315.24
7.2.230.0070.09315.25
7.2.220.0070.10615.13
7.2.210.0050.09015.10
7.2.200.0030.08915.24
7.2.190.0030.08915.19
7.2.180.0050.09315.22
7.2.170.0030.09315.12
7.2.160.0020.10315.15
7.2.150.0080.08717.09
7.2.140.0070.11017.06
7.2.130.0030.08716.95
7.2.120.0080.08717.10
7.2.110.0060.08816.92
7.2.100.0080.08817.11
7.2.90.0030.08616.99
7.2.80.0020.09817.02
7.2.70.0080.09217.11
7.2.60.0070.09516.93
7.2.50.0060.09817.00
7.2.40.0050.09117.09
7.2.30.0050.08516.95
7.2.20.0030.09717.08
7.2.10.0030.09817.00
7.2.00.0060.09317.63
7.1.330.0030.09215.96
7.1.320.0100.09915.85
7.1.310.0050.08315.72
7.1.300.0030.10615.80
7.1.290.0050.09615.68
7.1.280.0020.08415.64
7.1.270.0020.08615.85
7.1.260.0020.09215.81
7.1.250.0070.08515.88
7.1.240.0000.14015.76
7.1.230.0070.08415.78
7.1.220.0000.09415.71
7.1.210.0030.09415.89
7.1.200.0070.09815.71
7.1.190.0030.12515.65
7.1.180.0030.08915.88
7.1.170.0030.09615.98
7.1.160.0070.08615.90
7.1.150.0000.09015.84
7.1.140.0030.10615.66
7.1.130.0000.09115.77
7.1.120.0070.08415.64
7.1.110.0030.08615.62
7.1.100.0000.12216.94
7.1.90.0030.10415.86
7.1.80.0070.09916.04
7.1.70.0030.09216.33
7.1.60.0080.11317.52
7.1.50.0100.11525.37
7.1.40.0030.09715.77
7.1.30.0000.08815.91
7.1.20.0070.07715.72
7.1.10.0100.10615.75
7.1.00.0050.16319.09
7.0.330.0030.14315.42
7.0.320.0070.07915.39
7.0.310.0030.13015.52
7.0.300.0030.08315.45
7.0.290.0070.09215.52
7.0.280.0030.08615.52
7.0.270.0030.10315.39
7.0.260.0030.08515.49
7.0.250.0100.11215.46
7.0.240.0000.11415.33
7.0.230.0030.10015.47
7.0.220.0070.09015.27
7.0.210.0030.10815.53
7.0.200.0030.09115.98
7.0.190.0000.12515.16
7.0.180.0030.08215.50
7.0.170.0060.08415.38
7.0.160.0030.08415.41
7.0.150.0030.12115.56
7.0.140.0030.14115.31
7.0.130.0030.10815.34
7.0.120.0030.08415.39
7.0.110.0030.16015.32
7.0.100.0000.09015.50
7.0.90.0000.15315.65
7.0.80.0120.11417.77
7.0.70.0050.11017.66
7.0.60.0220.11817.74
7.0.50.0080.11217.83
7.0.40.0020.09416.79
7.0.30.0100.11416.75
7.0.20.0050.09516.82
7.0.10.0070.10116.82
7.0.00.0070.09016.78
5.6.400.0000.11514.75
5.6.390.0070.10814.75
5.6.380.0070.07914.41
5.6.370.0030.14414.68
5.6.360.0000.08714.32
5.6.350.0130.07914.39
5.6.340.0070.09314.59
5.6.330.0030.10114.29
5.6.320.0030.09414.52
5.6.310.0000.08714.69
5.6.300.0070.08314.56
5.6.290.0030.09314.62
5.6.280.0020.10117.77
5.6.270.0000.08814.61
5.6.260.0070.15614.42
5.6.250.0030.09714.30
5.6.240.0030.08114.49
5.6.230.0050.10117.68
5.6.220.0070.12317.45
5.6.210.0030.11417.53
5.6.200.0030.10917.71
5.6.190.0020.10117.65
5.6.180.0050.12117.96
5.6.170.0120.11017.72
5.6.160.0030.09117.69
5.6.150.0050.10017.87
5.6.140.0030.12117.77
5.6.130.0070.10117.79
5.6.120.0070.13217.75
5.6.110.0030.11017.70
5.6.100.0100.13017.81
5.6.90.0050.14117.56
5.6.80.0070.14417.47
5.6.70.0050.10917.33
5.6.60.0120.16617.47
5.6.50.0120.12917.41
5.6.40.0030.11817.55
5.6.30.0120.13717.36
5.6.20.0100.14517.43
5.6.10.0070.14517.30
5.6.00.0070.14617.34
5.5.380.0000.14014.54
5.5.370.0030.09417.35
5.5.360.0030.08917.19
5.5.350.0030.10817.41
5.5.340.0000.10417.58
5.5.330.0150.10717.54
5.5.320.0070.11617.59
5.5.310.0050.09917.68
5.5.300.0080.09417.66
5.5.290.0080.13717.48
5.5.280.0100.15917.53
5.5.270.0220.11317.62
5.5.260.0020.12217.61
5.5.250.0020.15817.55
5.5.240.0050.11717.23
5.5.230.0030.14017.29
5.5.220.0020.17317.25
5.5.210.0050.14417.26
5.5.200.0020.10217.14
5.5.190.0050.10217.22
5.5.180.0020.12717.33
5.5.170.0100.13514.06
5.5.160.0030.14617.32
5.5.150.0050.10317.10
5.5.140.0120.11517.30
5.5.130.0100.14917.16
5.5.120.0080.13617.40
5.5.110.0030.16417.35
5.5.100.0080.13717.29
5.5.90.0080.12017.00
5.5.80.0050.14217.33
5.5.70.0050.12217.14
5.5.60.0080.13217.23
5.5.50.0080.12317.25
5.5.40.0050.12917.11
5.5.30.0100.13517.13
5.5.20.0070.15317.12
5.5.10.0080.13617.29
5.5.00.0080.12617.02
5.4.450.0020.16315.44
5.4.440.0030.21015.55
5.4.430.0020.22915.48
5.4.420.0020.19115.54
5.4.410.0050.25015.51
5.4.400.0030.25115.30
5.4.390.0030.22515.37
5.4.380.0020.18815.25
5.4.370.0070.19415.29
5.4.360.0080.24615.38
5.4.350.0100.24315.34
5.4.340.0100.24815.39
5.4.330.0030.18411.64
5.4.320.0080.19715.44
5.4.310.0070.21015.32
5.4.300.0100.21815.44
5.4.290.0030.26315.38
5.4.280.0050.19615.34
5.4.270.0120.22715.29
5.4.260.0030.21615.33
5.4.250.0100.20615.25
5.4.240.0080.21115.38
5.4.230.0070.21015.33
5.4.220.0120.20215.27
5.4.210.0030.21315.24
5.4.200.0030.23215.40
5.4.190.0030.20515.29
5.4.180.0030.18415.38
5.4.170.0050.18615.43
5.4.160.0050.22315.38
5.4.150.0080.20415.26
5.4.140.0070.19414.08
5.4.130.0070.19714.01
5.4.120.0030.22614.04
5.4.110.0070.26014.10
5.4.100.0030.20014.06
5.4.90.0070.22014.05
5.4.80.0280.17714.06
5.4.70.0100.18514.02
5.4.60.0000.21214.09
5.4.50.0070.19513.98
5.4.40.0100.22614.05
5.4.30.0080.20214.04
5.4.20.0020.23013.95
5.4.10.0050.20014.06
5.4.00.0030.17913.75

preferences:
41.99 ms | 401 KiB | 5 Q