3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * La fonction sodium_crypto_box_keypair() génère aléatoirement une clé secrète * et une clé publique correspondante. */ $aliceKeypair = sodium_crypto_box_keypair(); $alicePublicKey = sodium_crypto_box_publickey($aliceKeypair); $aliceSecretKey = sodium_crypto_box_secretkey($aliceKeypair); $bobKeypair = sodium_crypto_box_keypair(); $bobPublicKey = sodium_crypto_box_publickey($bobKeypair); $bobSecretKey = sodium_crypto_box_secretkey($bobKeypair); /** * Le nombre arbitraire n'a pas besoin d'être confidentiel, mais il doit être * utilisé avec une seule invocation de crypto_box_open() pour une paire * particulière de clés publiques et secrètes. */ $nonce = random_bytes(SODIUM_CRYPTO_SECRETBOX_NONCEBYTES); $aliceToBobKeyPair = sodium_crypto_box_keypair_from_secretkey_and_publickey($aliceSecretKey, $bobPublicKey); $message = 'Signed using Alice\'s secret key and to be encrypted using Bob\'s public key.'; $ciphertext = sodium_crypto_box($message, $nonce, $aliceToBobKeyPair); $bobToAliceKp = sodium_crypto_box_keypair_from_secretkey_and_publickey($bobSecretKey, $alicePublicKey); $plaintext = sodium_crypto_box_open($ciphertext, $nonce, $bobToAliceKp); echo $plaintext;

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.0040.01215.05
7.4.00.0060.01114.86
7.3.130.0040.01414.97
7.3.120.0090.01015.03
7.3.110.0040.01314.87
7.3.100.0080.00414.63
7.3.90.0110.00214.92
7.3.80.0070.01014.64
7.3.70.0090.00814.70
7.3.60.0080.00314.77
7.3.50.0070.00614.47
7.3.40.0050.00714.59
7.3.30.0070.00514.69
7.3.20.0090.00316.54
7.3.10.0080.00616.50
7.3.00.0030.00916.65
7.2.260.0060.01215.11
7.2.250.0060.01114.93
7.2.240.0070.01015.15
7.2.230.0020.01515.23
7.2.220.0060.00915.24
7.2.210.0100.00615.04
7.2.200.0060.01015.27
7.2.190.0000.01015.16
7.2.180.0060.00615.04
7.2.170.0060.01115.15
7.2.160.0060.00915.11
7.2.150.0060.00617.14
7.2.140.0120.00617.05
7.2.130.0020.01116.84
7.2.120.0080.00916.95
7.2.110.0030.01216.76
7.2.100.0090.00716.87
7.2.90.0020.01117.03
7.2.80.0080.00316.93
7.2.70.0040.00917.11
7.2.60.0070.00516.97
7.2.50.0090.00717.00
7.2.40.0030.00916.68
7.2.30.0020.01216.89
7.2.20.0080.00716.97
7.2.10.0100.00516.93
7.2.00.0350.00916.19
7.1.330.0080.00715.54
7.1.320.0050.01015.76
7.1.310.0080.00715.64
7.1.300.0030.00815.48
7.1.290.0030.00915.47
7.1.280.0060.00915.67
7.1.270.0010.01015.44
7.1.260.0040.00815.65
7.1.250.0050.00815.67
7.1.240.0040.00715.65
7.1.230.0030.00815.74
7.1.220.0050.00815.62
7.1.210.0060.00615.67
7.1.200.0050.00615.76
7.1.190.0050.01015.46
7.1.180.0050.00515.75
7.1.170.0060.00315.51
7.1.160.0040.00715.59
7.1.150.0060.00515.73
7.1.140.0060.00715.66
7.1.130.0030.00715.72
7.1.120.0210.00514.95
7.1.110.0310.00915.01
7.1.100.0430.00814.90
7.1.90.0420.00314.97
7.1.80.0190.00515.06
7.1.70.0310.00714.95
7.1.60.0190.01021.00
7.1.50.0320.00920.94
7.1.40.0250.00920.97
7.1.30.0620.00821.03
7.1.20.0440.01020.88
7.1.10.0360.00214.96
7.1.00.0340.00514.90
7.0.330.0070.00515.30
7.0.320.0040.00815.52
7.0.310.0110.00415.14
7.0.300.0070.00715.00
7.0.290.0060.00615.30
7.0.280.0070.00315.01
7.0.270.0000.00915.02
7.0.260.0070.00715.25
7.0.250.0030.00615.27
7.0.240.0000.01415.45
7.0.230.0060.00715.48
7.0.220.0080.00415.16
7.0.210.0060.00915.30
7.0.200.0040.00415.47
7.0.190.0070.01115.02
7.0.180.0040.01115.35
7.0.170.0000.01515.45
7.0.160.0070.00715.32
7.0.150.0030.01015.35
7.0.140.0030.01215.51
7.0.130.0040.00815.23
7.0.120.0070.00715.05
7.0.110.0030.00915.34
7.0.100.0080.00415.10
7.0.90.0060.00315.05
7.0.80.0030.00715.36
7.0.70.0100.00715.50
7.0.60.0090.00615.13
7.0.50.0030.01015.36
7.0.40.0060.00613.32
7.0.30.0060.00913.22
7.0.20.0000.01213.40
7.0.10.0030.00713.08
7.0.00.0060.00613.09
5.6.400.0060.00914.39
5.6.390.0080.00013.82
5.6.380.0020.01014.22
5.6.370.0000.01314.16
5.6.360.0150.00314.26
5.6.350.0000.01313.94
5.6.340.0100.00314.07
5.6.330.0090.00314.00
5.6.320.0100.00314.02
5.6.310.0080.00313.92
5.6.300.0060.00914.28
5.6.290.0090.00614.29
5.6.280.0040.01114.18
5.6.270.0000.01414.42
5.6.260.0040.00813.87
5.6.250.0040.01114.20
5.6.240.0100.00714.18
5.6.230.0060.00914.04
5.6.220.0030.01014.29
5.6.210.0060.00614.26
5.6.200.0060.00614.39
5.6.190.0030.00614.19
5.6.180.0070.00314.16
5.6.170.0060.00614.07
5.6.160.0030.01014.10
5.6.150.0000.01114.05
5.6.140.0060.00314.48
5.6.130.0060.00314.10
5.6.120.0000.01113.99
5.6.110.0100.00314.23
5.6.100.0000.01414.00
5.6.90.0060.00914.04
5.6.80.0030.00614.08
5.6.70.0060.00614.06
5.6.60.0030.00714.13
5.6.50.0000.01114.00
5.6.40.0000.01113.75
5.6.30.0030.01314.11
5.6.20.0000.00814.11
5.6.10.0060.00914.00
5.6.00.0070.01014.09

preferences:
32.62 ms | 401 KiB | 5 Q