UNPKG

dmclc

Version:

Dolphin Minecraft Launcher Core

12 lines (11 loc) 392 B
import * as crypto from "crypto"; import fs from "fs"; import fsPromises from 'fs/promises'; export async function checkFile(filename, hash, algorithm = "sha1") { if (!fs.existsSync(filename)) return false; if (hash === "") return true; const val = await fsPromises.readFile(filename); return crypto.createHash(algorithm).update(val).digest("hex") === hash; }