@@ 40-55 (lines=16) @@ | ||
37 | \hash_update($context, $data); |
|
38 | $this->emit('data', [$data]); |
|
39 | }); |
|
40 | $this->stream->once('end', function () use ($context, $algo): void { |
|
41 | $hash = \hash_final($context, true); |
|
42 | if (\count($this->listeners('hash')) > 0) { |
|
43 | $this->emit('hash', [ |
|
44 | \bin2hex($hash), |
|
45 | $algo, |
|
46 | ]); |
|
47 | } |
|
48 | if (\count($this->listeners('hash_raw')) > 0) { |
|
49 | $this->emit('hash_raw', [ |
|
50 | $hash, |
|
51 | $algo, |
|
52 | ]); |
|
53 | } |
|
54 | $this->emit('end'); |
|
55 | }); |
|
56 | Util::forwardEvents($stream, $this, ['error', 'close']); |
|
57 | } |
|
58 |
@@ 35-50 (lines=16) @@ | ||
32 | $options[] = $key; |
|
33 | } |
|
34 | $this->context = \hash_init(...$options); |
|
35 | $this->stream->once('close', function () use ($algo): void { |
|
36 | $hash = \hash_final($this->context, true); |
|
37 | if (\count($this->listeners('hash')) > 0) { |
|
38 | $this->emit('hash', [ |
|
39 | \bin2hex($hash), |
|
40 | $algo, |
|
41 | ]); |
|
42 | } |
|
43 | if (\count($this->listeners('hash_raw')) > 0) { |
|
44 | $this->emit('hash_raw', [ |
|
45 | $hash, |
|
46 | $algo, |
|
47 | ]); |
|
48 | } |
|
49 | $this->emit('close'); |
|
50 | }); |
|
51 | } |
|
52 | ||
53 | public function isWritable() |