mirror of
https://github.com/opentofu/setup-opentofu.git
synced 2026-11-29 11:34:36 +01:00
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:
1 parent
03a9076efe
commit
4bcfe8cded
6 files changed
+153
-7
No files matched your search
+16
@@ -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');
|
||||
}
|
||||
Reference in new issue
Block a user