Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/hash/calcHash.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
import {createReadStream} from "fs";
import {dirname} from "../utils/dir.js";

const calculateHash = async () => {
// Write your code here
const { createHash } = await import('node:crypto');

const __dirname = dirname(import.meta.url);
const hash = createHash('sha256');
const readStream = createReadStream(`${__dirname}/files/fileToCalculateHashFor.txt`);

readStream.pipe(hash)
.setEncoding('hex')
.pipe(process.stdout);
};

await calculateHash();