3v4l.org

run code in 300+ PHP versions simultaneously
<?php function _xor($text,$key){ $outText = ''; for($i=0;$i<strlen($text);) { for($j=0;($j<strlen($key) && $i<strlen($text));$j++,$i++) { $outText .= $text{$i} ^ $key{$j}; } } return $outText; } $encoding_key = 'c422fdd0d81f'; // Encoding key and integrity key will $integrity_key = 'fe3fd7dd8731'; // be exchanged between you and Improve Digital $algo = 'sha1'; // HMAC algorithm used $price = 300; // Price to be encrypted. Up to 8 Bytes, treated as string // 1. Create a (hopefully) unique 16-byte initialization string: // This is an example and can be replaced by something faster if needed $initialization_vector = substr(hash("sha256", microtime(TRUE).rand(0,9999).time()),0,16); // 2. Encrypt the price: // The encrypted price is the result of a bitwise XOR (^) of the price and a HMAC-Hash of // the initialization string and the encoding key. Since xor does not bloat or shrink the // encrypted string, we are already changing the input to 8 bytes. // // Common pitfalls: // - Price to be encrypted MUST be a string. It will most likely behave unexpected if // treated as float // - Hash has to be RAW output (TRUE Parameter). If missed out, lowercase hexits will be // used and cause decryption to fail. $encrypted_price = _xor( substr(number_format($price,8),0,8), hash_hmac($algo, $initialization_vector,$encoding_key, TRUE )); // 3. Create the integrity // Another hash to be created to allow verification of the decrypted price. Integrity // key instead of encryption key is used // Only the first 4 Bytes are being used so the rest is omitted immediately. $integrity = substr(hash_hmac($algo, substr(number_format($price,8),0,8).$initialization_vector, $integrity_key, TRUE),0,4); // 4. Glue the parts togetger // 16 byte initialization string + 8 bytes encrypted price + 4 bytes of integrity will be // base64-encoded $out = base64_encode($initialization_vector.$encrypted_price.$integrity); // 5. Replace / with . and + with - to make the encoded string URL-safe. $urlsafe = str_replace('/','.',str_replace('+', '-', $out)); echo $urlsafe; // Done

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.00.0070.01014.81
7.3.120.0070.01115.02
7.3.110.0070.01015.14
7.3.100.0060.00914.79
7.3.90.0060.00614.81
7.3.80.0040.00915.00
7.3.70.0060.00614.80
7.3.60.0060.00914.54
7.3.50.0070.00714.45
7.3.40.0110.00715.00
7.3.30.0100.00314.82
7.3.20.0070.00716.84
7.3.10.0060.01016.62
7.3.00.0030.01116.76
7.2.250.0100.01015.04
7.2.240.0070.01115.32
7.2.230.0070.00714.91
7.2.220.0000.01314.95
7.2.210.0090.00615.14
7.2.200.0100.00315.17
7.2.190.0000.01214.89
7.2.180.0100.00614.70
7.2.170.0100.00315.16
7.2.00.0030.00919.52
7.1.330.0120.00415.87
7.1.320.0040.01215.43
7.1.310.0030.01415.57
7.1.300.0090.00615.79
7.1.290.0060.00615.69
7.1.280.0040.00415.55
7.1.270.0070.00715.77
7.1.260.0090.00615.63
7.1.70.0060.01017.19
7.1.60.0110.01419.82
7.1.50.0070.01416.93
7.1.00.0000.08022.28
7.0.200.0030.01216.53
7.0.140.0030.07322.10
7.0.110.0100.07721.87
7.0.100.0100.07321.68
7.0.90.0070.08721.80
7.0.80.0000.08021.70
7.0.70.0070.07721.71
7.0.60.0100.07021.73
7.0.50.0070.07721.76
7.0.40.0030.08019.89
7.0.30.0030.08019.75
7.0.20.0100.08019.70
7.0.10.0100.08019.78
7.0.00.0070.07719.74
5.6.280.0130.06721.05
5.6.260.0100.07720.61
5.6.250.0030.08320.52
5.6.240.0070.08020.49
5.6.230.0070.08020.63
5.6.220.0100.07320.64
5.6.210.0000.05720.63
5.6.200.0030.08320.72
5.6.190.0000.08320.64
5.6.180.0130.07020.65
5.6.170.0100.07320.65
5.6.160.0030.08320.86
5.6.150.0170.07020.60
5.6.140.0130.07320.47
5.6.130.0030.08720.65
5.6.120.0070.08720.66
5.6.110.0130.04720.61
5.6.100.0030.04720.46
5.6.90.0030.04020.69
5.6.80.0100.03319.98
5.6.70.0030.04720.06
5.6.60.0070.06720.09
5.6.50.0100.05020.05
5.6.40.0030.04020.02
5.6.30.0030.04020.01
5.6.20.0100.03319.93
5.6.10.0030.07319.98
5.6.00.0070.06719.97
5.5.380.0030.08017.70
5.5.370.0070.06717.43
5.5.360.0070.07717.59
5.5.350.0070.08017.78
5.5.340.0070.08318.09
5.5.330.0000.08018.10
5.5.320.0070.08018.25
5.5.310.0100.07718.10
5.5.300.0100.05717.93
5.5.290.0030.08017.91
5.5.280.0100.08318.25
5.5.270.0100.04318.24
5.5.260.0030.04318.09
5.5.250.0100.03317.74
5.5.240.0130.04717.34
5.5.230.0100.05317.63
5.5.220.0030.03717.47
5.5.210.0070.06017.29
5.5.200.0100.05017.41
5.5.190.0070.03317.18
5.5.180.0070.04317.26
5.5.160.0030.03717.45
5.5.150.0030.04717.26
5.5.140.0000.04017.58
5.5.130.0000.04017.45
5.5.120.0030.04717.28
5.5.110.0000.04317.42
5.5.100.0030.04317.17
5.5.90.0070.03317.32
5.5.80.0000.05717.29
5.5.70.0030.03717.33
5.5.60.0030.03717.16
5.5.50.0100.07317.33
5.5.40.0100.06717.38
5.5.30.0030.07017.14
5.5.20.0130.07017.14
5.5.10.0170.06717.17
5.5.00.0100.07017.37
5.4.450.0170.07019.57
5.4.440.0130.07319.34
5.4.430.0030.06019.46
5.4.420.0070.04019.46
5.4.410.0100.03319.27
5.4.400.0070.03719.07
5.4.390.0070.03019.25
5.4.380.0030.03319.18
5.4.370.0070.03719.06
5.4.360.0070.04719.31
5.4.350.0000.04019.24
5.4.340.0000.07019.23
5.4.320.0070.03319.25
5.4.310.0070.03319.25
5.4.300.0000.04719.07
5.4.290.0030.06319.01
5.4.280.0000.04019.22
5.4.270.0070.03319.00
5.4.260.0200.04019.31
5.4.250.0130.02319.33
5.4.240.0030.03719.06
5.4.230.0030.05719.05
5.4.220.0070.03719.01
5.4.210.0000.04319.30
5.4.200.0070.07719.30
5.4.190.0100.07319.30
5.4.180.0030.08019.04
5.4.170.0030.08019.08
5.4.160.0130.07318.99
5.4.150.0070.06019.08
5.4.140.0030.06316.46
5.4.130.0000.07716.45
5.4.120.0100.07016.35
5.4.110.0030.06716.43
5.4.100.0100.07316.33
5.4.90.0030.07716.59
5.4.80.0030.06316.56
5.4.70.0130.06016.49
5.4.60.0070.07716.53
5.4.50.0070.06716.54
5.4.40.0130.07016.36
5.4.30.0100.07316.53
5.4.20.0070.07716.53
5.4.10.0200.06316.47
5.4.00.0100.07715.86
5.3.290.0030.04014.75
5.3.280.0030.04714.59
5.3.270.0100.08014.59
5.3.260.0030.07714.85
5.3.250.0070.07714.84
5.3.240.0130.06714.59
5.3.230.0070.08014.68
5.3.220.0100.07014.67
5.3.210.0070.06714.77
5.3.200.0030.08314.72
5.3.190.0100.07314.72
5.3.180.0070.07314.58
5.3.170.0100.07314.70
5.3.160.0070.07014.77
5.3.150.0000.08014.50
5.3.140.0030.06714.67
5.3.130.0100.07314.48
5.3.120.0130.07314.69
5.3.110.0100.07014.54
5.3.100.0200.05714.05
5.3.90.0030.07714.11
5.3.80.0170.06314.04
5.3.70.0100.07014.06
5.3.60.0170.06713.99
5.3.50.0100.07313.98
5.3.40.0100.03714.02
5.3.30.0100.06013.78
5.3.20.0100.07013.79
5.3.10.0100.05313.80
5.3.00.0070.07013.61
5.2.170.0030.06011.34
5.2.160.0100.05711.29
5.2.150.0070.05711.38
5.2.140.0070.05711.33
5.2.130.0070.06011.52
5.2.120.0030.06311.29
5.2.110.0030.06311.28
5.2.100.0070.05711.25
5.2.90.0070.06311.32
5.2.80.0130.06011.30
5.2.70.0030.06011.30
5.2.60.0030.06311.23
5.2.50.0000.07011.23
5.2.40.0070.06011.34
5.2.30.0170.04011.23
5.2.20.0070.05711.23
5.2.10.0130.05011.23
5.2.00.0130.05311.23
5.1.60.0070.05311.23
5.1.50.0070.05311.23
5.1.40.0070.05311.23
5.1.30.0100.04711.23
5.1.20.0070.05711.23
5.1.10.0000.06011.23
5.1.00.0070.05311.23
5.0.50.0000.05011.23
5.0.40.0000.04711.23
5.0.30.0070.06711.23
5.0.20.0000.05011.23
5.0.10.0100.04011.23
5.0.00.0070.06711.23
4.4.90.0000.02711.23
4.4.80.0000.03311.23
4.4.70.0100.03011.23
4.4.60.0070.03311.23
4.4.50.0000.02311.23
4.4.40.0030.05311.23
4.4.30.0100.03011.23
4.4.20.0000.03711.23
4.4.10.0030.03011.23
4.4.00.0030.04311.23
4.3.110.0070.03011.23
4.3.100.0030.03711.23
4.3.90.0030.03011.23
4.3.80.0000.05711.23
4.3.70.0070.02011.23
4.3.60.0000.03011.23
4.3.50.0030.03311.23
4.3.40.0000.05311.23
4.3.30.0000.03311.23
4.3.20.0030.03311.23
4.3.10.0000.02011.23
4.3.00.0000.02311.23

preferences:
31.77 ms | 401 KiB | 5 Q