3v4l.org

run code in 300+ PHP versions simultaneously
<?php $hashAlgo = 'sha384'; //$hashAlgo = 'sha256'; $maxHeaderLength = 2048; // $maxHeaderLength = 3072; // Do not change after here $baseCsp = "default-src 'self'; report-uri https://www.my-super-domain.com/_contao/csp/report/51; style-src 'self' 'unsafe-hashes' 'nonce-H0Sss0Ol1d/r/rgWp4sRk3IT'; script-src 'self' 'unsafe-hashes' 'nonce-H0Sss0Ol1d/r/rgWp4sRk3IT'"; // + 3 for wrapping '' and space $lengthOfOneHash = strlen($hashAlgo . '-' . base64_encode(hash($hashAlgo, 'text-decoration: underline'))) + 3; $count = 0; $total = strlen($baseCsp); while (true) { $total += $lengthOfOneHash; if ($total > $maxHeaderLength) { echo 'Could fit ' . $count . ' hashes in the CSP header.'; break; } $count++; }
Output for git.master_jit, git.master, rfc.property-hooks
Could fit 13 hashes in the CSP header.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
18.38 ms | 401 KiB | 8 Q