feat: added support for providing optional checksums for ZIP validation (#107)

Signed-off-by: Kim <kim.peter.wagner@gmail.com>
This commit is contained in:
Kim Wagner authored and GitHub committed 2026-04-13 16:46:38 -03:00
1 parent 03a9076efe
commit 4bcfe8cded
6 files changed
+153 -7

No files matched your search

+16
View File
@@ -0,0 +1,16 @@
/**
* Copyright (c) OpenTofu
* SPDX-License-Identifier: MPL-2.0
*/
import { createHash } from 'crypto';
import { createReadStream } from 'fs';
import { pipeline } from 'stream/promises';
export async function fileSHA256 (filePath) {
const hash = createHash('sha256');
const fileStream = createReadStream(filePath);
await pipeline(fileStream, hash);
return hash.digest('hex');
}