Skip to content

Commit 2ae5d85

Browse files
aduh95ruyadorno
authored andcommitted
doc: fix code examples in crypto.md
PR-URL: #44053 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Mestery <mestery@protonmail.com> Reviewed-By: Feng Yu <F3n67u@outlook.com>
1 parent 1b9537b commit 2ae5d85

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

doc/api/crypto.md

+7-5
Original file line numberDiff line numberDiff line change
@@ -395,11 +395,11 @@ Example: Using `Cipher` and piped streams:
395395
import {
396396
createReadStream,
397397
createWriteStream,
398-
} from 'fs';
398+
} from 'node:fs';
399399

400400
import {
401401
pipeline
402-
} from 'stream';
402+
} from 'node:stream';
403403

404404
const {
405405
scrypt,
@@ -675,6 +675,7 @@ const decipher = createDecipheriv(algorithm, key, iv);
675675

676676
let decrypted = '';
677677
decipher.on('readable', () => {
678+
let chunk;
678679
while (null !== (chunk = decipher.read())) {
679680
decrypted += chunk.toString('utf8');
680681
}
@@ -711,6 +712,7 @@ const decipher = createDecipheriv(algorithm, key, iv);
711712

712713
let decrypted = '';
713714
decipher.on('readable', () => {
715+
let chunk;
714716
while (null !== (chunk = decipher.read())) {
715717
decrypted += chunk.toString('utf8');
716718
}
@@ -733,7 +735,7 @@ Example: Using `Decipher` and piped streams:
733735
import {
734736
createReadStream,
735737
createWriteStream,
736-
} from 'fs';
738+
} from 'node:fs';
737739
import { Buffer } from 'node:buffer';
738740
const {
739741
scryptSync,
@@ -3305,7 +3307,7 @@ Example: generating the sha256 sum of a file
33053307
```mjs
33063308
import {
33073309
createReadStream
3308-
} from 'fs';
3310+
} from 'node:fs';
33093311
import { argv } from 'node:process';
33103312
const {
33113313
createHash
@@ -3391,7 +3393,7 @@ Example: generating the sha256 HMAC of a file
33913393
```mjs
33923394
import {
33933395
createReadStream
3394-
} from 'fs';
3396+
} from 'node:fs';
33953397
import { argv } from 'node:process';
33963398
const {
33973399
createHmac

0 commit comments

Comments
 (0)