From 477a52e779df1b5c581ad0b1215bccef095bb18c Mon Sep 17 00:00:00 2001 From: Niels Leenheer Date: Fri, 20 Nov 2020 11:05:59 +0100 Subject: [PATCH] fix: use setEncoding() and read() for crypto.createHash instead of digest() (#11) --- src/sha.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sha.ts b/src/sha.ts index a56add5..5ab64e1 100644 --- a/src/sha.ts +++ b/src/sha.ts @@ -5,11 +5,12 @@ import { d } from './debug'; export const sha = async (filePath: string) => { d('hashing', filePath); const hash = crypto.createHash('sha256'); + hash.setEncoding('hex'); const fileStream = fs.createReadStream(filePath); fileStream.pipe(hash); await new Promise((resolve, reject) => { fileStream.on('end', () => resolve()); fileStream.on('error', (err) => reject(err)); }); - return hash.digest('hex'); + return hash.read(); };