Skip to content

Commit 44f2717

Browse files
authored
Use hash_update_stream to compute hash on resource (#360)
1 parent 6c488bf commit 44f2717

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/Stream/ResourceStream.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,9 @@ public function hash(string $algo = 'sha256', bool $raw = false): string
8484
}
8585

8686
$ctx = hash_init($algo);
87-
while (!feof($this->content)) {
88-
hash_update($ctx, fread($this->content, 1048576));
89-
}
90-
87+
hash_update_stream($ctx, $this->content);
9188
$out = hash_final($ctx, $raw);
89+
9290
if (-1 === fseek($this->content, $pos)) {
9391
throw new InvalidArgument('Unable to seek the content.');
9492
}

0 commit comments

Comments
 (0)