photosite/dist/hash/index.js

16 lines
592 B
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.hash = hash;
const fs_1 = require("fs");
const crypto_1 = require("crypto");
function hash(path) {
return new Promise((resolve, reject) => {
const hashSum = (0, crypto_1.createHash)('sha256');
const stream = (0, fs_1.createReadStream)(path);
stream.on('error', (err) => reject(err));
stream.on('data', (chunk) => hashSum.update(chunk));
stream.on('end', () => resolve(hashSum.digest('hex')));
});
}
module.exports = { hash };
//# sourceMappingURL=index.js.map