/** * @param \HttpDigest\Algorithm\AlgorithmInterface $algorithm * @param string|\Psr\Http\Message\StreamInterface $data * * @return string */ private function getHash(AlgorithmInterface $algorithm, $data) { if ($data instanceof StreamInterface) { $hash = $algorithm->getHashOfStream($data); } else { $hash = $algorithm->getHash($data); } if ($algorithm->getDigestSize() / 4 < strlen($hash)) { $hash = substr($hash, 0, $algorithm->getDigestSize() / 4); } return $hash; }
/** * @param \HttpDigest\Algorithm\AlgorithmInterface $scheme_algorithm */ public function addSchemeAlgorithms(AlgorithmInterface $scheme_algorithm) { if (!$this->hasSchemeAlgorithm($scheme_algorithm->getName())) { $this->scheme_algorithms[$scheme_algorithm->getName()] = $scheme_algorithm; } }