From 8c25987e5129d64ae6c1d6a4367b06cf80297578 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Sat, 30 Jul 2022 17:11:50 +0200 Subject: [PATCH] doc: fix code examples in `crypto.md` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/44053 Reviewed-By: Tobias Nießen Reviewed-By: Mestery Reviewed-By: Feng Yu --- doc/api/crypto.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/doc/api/crypto.md b/doc/api/crypto.md index f4dd56b8d61..8d6c5a94f90 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -395,11 +395,11 @@ Example: Using `Cipher` and piped streams: import { createReadStream, createWriteStream, -} from 'fs'; +} from 'node:fs'; import { pipeline -} from 'stream'; +} from 'node:stream'; const { scrypt, @@ -675,6 +675,7 @@ const decipher = createDecipheriv(algorithm, key, iv); let decrypted = ''; decipher.on('readable', () => { + let chunk; while (null !== (chunk = decipher.read())) { decrypted += chunk.toString('utf8'); } @@ -711,6 +712,7 @@ const decipher = createDecipheriv(algorithm, key, iv); let decrypted = ''; decipher.on('readable', () => { + let chunk; while (null !== (chunk = decipher.read())) { decrypted += chunk.toString('utf8'); } @@ -733,7 +735,7 @@ Example: Using `Decipher` and piped streams: import { createReadStream, createWriteStream, -} from 'fs'; +} from 'node:fs'; import { Buffer } from 'node:buffer'; const { scryptSync, @@ -3287,7 +3289,7 @@ Example: generating the sha256 sum of a file ```mjs import { createReadStream -} from 'fs'; +} from 'node:fs'; import { argv } from 'node:process'; const { createHash @@ -3373,7 +3375,7 @@ Example: generating the sha256 HMAC of a file ```mjs import { createReadStream -} from 'fs'; +} from 'node:fs'; import { argv } from 'node:process'; const { createHmac