mirror of
https://github.com/opentofu/setup-opentofu.git
synced 2026-11-26 18:30:54 +01:00
17 lines
392 B
JavaScript
17 lines
392 B
JavaScript
/**
|
|
* 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');
|
|
}
|