Skip to content

Commit ade5fd4

Browse files
authored
doc: fix code examples in crypto.md
PR-URL: #44053 Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Mestery <[email protected]> Reviewed-By: Feng Yu <[email protected]>
1 parent 327030e commit ade5fd4

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,
@@ -3311,7 +3313,7 @@ Example: generating the sha256 sum of a file
33113313
```mjs
33123314
import {
33133315
createReadStream
3314-
} from 'fs';
3316+
} from 'node:fs';
33153317
import { argv } from 'node:process';
33163318
const {
33173319
createHash
@@ -3397,7 +3399,7 @@ Example: generating the sha256 HMAC of a file
33973399
```mjs
33983400
import {
33993401
createReadStream
3400-
} from 'fs';
3402+
} from 'node:fs';
34013403
import { argv } from 'node:process';
34023404
const {
34033405
createHmac

0 commit comments

Comments
 (0)