Skip to content

Commit 857e321

Browse files
vbarzanaMylesBorins
authored andcommitted
doc: set encoding to hex before piping hash
I found out that piping a hash to the stdout output would print a non-hex set of characters, however, the examples are intended to print out a hex-encoded output so, my proposal here is simple, we set the encoding to `hex` before piping the response of the hash algo by calling `hash.setEncoding('hex');`. With this the example is fixed PR-URL: #35338 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent f2635b3 commit 857e321

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

doc/api/crypto.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,7 @@ const fs = require('fs');
10301030
const hash = crypto.createHash('sha256');
10311031

10321032
const input = fs.createReadStream('test.js');
1033-
input.pipe(hash).pipe(process.stdout);
1033+
input.pipe(hash).setEncoding('hex').pipe(process.stdout);
10341034
```
10351035

10361036
Example: Using the [`hash.update()`][] and [`hash.digest()`][] methods:

0 commit comments

Comments
 (0)