ParagonIE\CSPBuilder\CSPBuilder::hash PHP Method

hash() public method

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