CityBEM-CityLayers-SaeedRay.../node_modules/electron-rebuild/lib/test/helpers/checksum.js

23 lines
815 B
JavaScript
Raw Permalink Normal View History

"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