mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 10:34:17 +00:00
18 lines
435 B
JavaScript
18 lines
435 B
JavaScript
import fs from "node:fs"
|
|
import crypto from "crypto"
|
|
|
|
export default async (file) => {
|
|
return new Promise((resolve, reject) => {
|
|
if (typeof file === "string") {
|
|
file = fs.createReadStream(file)
|
|
}
|
|
|
|
const hash = crypto.createHash("sha256")
|
|
|
|
file.on("data", (chunk) => hash.update(chunk))
|
|
|
|
file.on("end", () => resolve(hash.digest("hex")))
|
|
|
|
file.on("error", reject)
|
|
})
|
|
} |