23 lines
815 B
JavaScript
23 lines
815 B
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.determineChecksum = void 0;
|
|
const crypto = require("crypto");
|
|
const fs = require("fs-extra");
|
|
const util_1 = require("util");
|
|
const stream = require("stream");
|
|
const pipeline = util_1.promisify(stream.pipeline);
|
|
async function determineChecksum(filename) {
|
|
let calculated = '';
|
|
const file = fs.createReadStream(filename, { encoding: 'binary' });
|
|
const hasher = crypto.createHash('sha256', { defaultEncoding: 'binary' });
|
|
hasher.on('readable', () => {
|
|
const data = hasher.read();
|
|
if (data) {
|
|
calculated = data.toString('hex');
|
|
}
|
|
});
|
|
await pipeline(file, hasher);
|
|
return calculated;
|
|
}
|
|
exports.determineChecksum = determineChecksum;
|
|
//# sourceMappingURL=checksum.js.map
|