Skip to content

Commit

Permalink
doc: fix code examples in crypto.md
Browse files Browse the repository at this point in the history
PR-URL: #44053
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Mestery <mestery@protonmail.com>
Reviewed-By: Feng Yu <F3n67u@outlook.com>
  • Loading branch information
aduh95 authored and targos committed Sep 5, 2022
1 parent e0fd882 commit 918fccf
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions doc/api/crypto.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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');
}
Expand Down Expand Up @@ -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');
}
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 918fccf

Please sign in to comment.