for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Storeman\Hash\Algorithm;
abstract class AbstractPhpHashAlgorithm implements HashAlgorithmInterface
{
protected $context;
/**
* {@inheritdoc}
*/
public function initialize(): void
$this->context = hash_init($this->getPhpHashAlgorithmName());
}
public function digest(string $buffer): void
assert($this->context !== null, sprintf('Calling %s() on uninitialized context.', __FUNCTION__));
hash_update($this->context, $buffer);
public function finalize(): string
return hash_final($this->context);
* Allows to override the hash algo name.
*
* @return string
protected function getPhpHashAlgorithmName(): string
return $this->getName();