3v4l.org

run code in 500+ PHP versions simultaneously
<?php declare(strict_types = 1); /** * Bitbucket Webhook Signature * * @link https://stackoverflow.com/a/79425616/367456 */ enum BitbucketSignature { case sha256; case sha384; case sha512; public static function authContents( ?string $signature, string $payload, #[SensitiveParameter] string $secret ) : ?string { if (null === $signature) return null; $algo = array_intersect_key( array_column(BitbucketSignature::cases(), null, 'name'), array_flip(hash_hmac_algos()), )[substr($signature, 0, 6)] ?? null; return ($algo instanceof self) && hash_equals($signature, "$algo->name=".hash_hmac($algo->name, $payload, $secret), ) ? $payload : null; } } $secret = "It's a Secret to Everybody"; $contents = BitbucketSignature::authContents( signature: @$_SERVER['HTTP_X_HUB_SIGNATURE'], payload: file_get_contents(filename: 'php://input'), secret: $secret, ); var_dump($contents); $signature = 'sha256=a4771c39fbe90f317c7824e83ddef3caae9cb3d976c214ace1f2937e133263c9'; $payload = 'Hello World!'; $contents = BitbucketSignature::authContents( signature: $signature, payload: $payload, secret: $secret, ); var_dump($contents);

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)
8.5.70.0070.00718.77
8.5.60.0090.00916.85
8.5.50.0120.00717.00
8.5.30.0100.00718.02
8.5.20.0110.00620.25
8.5.10.0130.00616.94
8.5.00.0140.00920.03
8.4.220.0080.01319.65
8.4.210.0130.01021.61
8.4.180.0110.01119.80
8.4.170.0060.00420.57
8.4.160.0150.00720.46
8.4.150.0020.00317.03
8.4.140.0160.00617.69
8.4.130.0130.00717.77
8.4.120.0130.00722.27
8.4.110.0110.00622.60
8.4.100.0110.01018.08
8.4.90.0130.00617.96
8.4.80.0110.01018.08
8.4.70.0130.00718.09
8.4.60.0060.00318.73
8.4.50.0160.00419.63
8.4.40.0070.01317.76
8.4.30.0370.01117.33
8.4.20.0330.01617.72
8.4.10.0380.01017.70
8.3.310.0040.00518.91
8.3.300.0140.00620.67
8.3.290.0120.00820.95
8.3.280.0140.00720.80
8.3.270.0100.00916.92
8.3.260.0110.00816.83
8.3.250.0100.00718.84
8.3.240.0120.00816.87
8.3.230.0080.00816.87
8.3.220.0110.00617.17
8.3.210.0110.00716.79
8.3.200.0130.00616.54
8.3.190.0050.00417.09
8.3.180.0060.00718.86
8.3.170.0110.00316.68
8.3.160.0430.00316.80
8.3.150.0180.00916.43
8.3.140.0300.00316.68
8.3.130.0150.00916.29
8.3.120.0290.01016.36
8.3.110.0360.00816.55
8.3.100.0260.00416.54
8.3.90.0160.00516.76
8.3.80.0170.00316.90
8.3.70.0180.00416.79
8.3.60.0290.00016.46
8.3.50.0360.01116.73
8.3.40.0410.00317.42
8.3.30.0270.01017.39
8.3.20.0330.00317.38
8.3.10.0090.00917.57
8.3.00.0120.00817.41
8.2.300.0130.00920.42
8.2.290.0080.01220.33
8.2.280.0090.01116.75
8.2.270.0350.00416.63
8.2.260.0260.01516.34
8.2.250.0240.01517.02
8.2.240.0190.01916.45
8.2.230.0180.00017.00
8.2.220.0160.00816.57
8.2.210.0150.00916.68
8.2.200.0310.00716.50
8.2.190.0230.01416.46
8.2.180.0230.00716.46
8.2.170.0190.00017.83
8.2.160.0090.00917.69
8.2.150.0140.00617.85
8.2.140.0370.00317.37
8.2.130.0370.00317.48
8.2.120.0250.01317.73
8.2.110.0300.00817.61
8.2.100.0360.00917.75
8.2.90.0310.00917.69
8.2.80.0230.02017.29
8.2.70.0320.00617.32
8.2.60.0330.00417.42
8.2.50.0330.00717.69
8.2.40.0360.00317.43
8.2.30.0280.00717.39
8.2.20.0320.00417.43
8.2.10.0230.01417.50
8.2.00.0240.01217.39
8.1.340.0140.00620.23
8.1.320.0100.01016.32

preferences:
58.23 ms | 863 KiB | 5 Q