diff --git a/src/HashingStream.php b/src/HashingStream.php index 6974460..52e9adb 100644 --- a/src/HashingStream.php +++ b/src/HashingStream.php @@ -64,9 +64,11 @@ public function read($length): string hash_update($this->hashResource, $read); } if ($this->stream->eof()) { - $this->hash = hash_final($this->hashResource, true); - if ($this->onComplete) { - call_user_func($this->onComplete, $this->hash); + if (!$this->hash) { + $this->hash = hash_final($this->hashResource, true); + if ($this->onComplete) { + call_user_func($this->onComplete, $this->hash); + } } } @@ -93,4 +95,4 @@ private function initializeHash(): void $this->key ); } -} \ No newline at end of file +}