ParagonIE\CSPBuilder\CSPBuilder::preHash PHP Method

preHash() public method

Add a new (pre-calculated) base64-encoded hash to the existing CSP
public preHash ( string $directive = 'script-src', string $hash = '', string $algorithm = 'sha384' ) : self
$directive string
$hash string
$algorithm string
return self
    public function preHash(string $directive = 'script-src', string $hash = '', string $algorithm = 'sha384') : self
    {
        $ruleKeys = \array_keys($this->policies);
        if (\in_array($directive, $ruleKeys)) {
            $this->policies[$directive]['hashes'][] = [$algorithm => $hash];
        }
        return $this;
    }