2024-01-08 20:38:27 +00:00
|
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
2024-12-05 19:55:12 +00:00
|
|
|
exports.Hashes = void 0;
|
2024-01-08 20:38:27 +00:00
|
|
|
const crypto_1 = require("crypto");
|
2024-12-05 19:55:12 +00:00
|
|
|
const fs_1 = require("fs");
|
|
|
|
class Hashes {
|
|
|
|
static async fileHash(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')));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
static stringHash(str) {
|
|
|
|
const sha = (0, crypto_1.createHash)('sha256').update(str);
|
|
|
|
return sha.digest('hex');
|
|
|
|
}
|
2024-01-08 20:38:27 +00:00
|
|
|
}
|
2024-12-05 19:55:12 +00:00
|
|
|
exports.Hashes = Hashes;
|
|
|
|
module.exports = { Hashes };
|
2024-01-08 20:38:27 +00:00
|
|
|
//# sourceMappingURL=index.js.map
|