Skip to content

Commit

Permalink
fix: use setEncoding() and read() for crypto.createHash instead of di…
Browse files Browse the repository at this point in the history
…gest() (#11)
  • Loading branch information
NielsLeenheer authored Nov 20, 2020
1 parent 107823f commit 477a52e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/sha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
};

0 comments on commit 477a52e

Please sign in to comment.