Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/src/util/node/crypto.ts
13397 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { createHash } from 'node:crypto';
7
import type { Readable } from 'node:stream';
8
9
export async function createSha256FromStream(stream: Readable): Promise<string> {
10
const hash = createHash('sha256');
11
for await (const chunk of stream) {
12
hash.update(chunk);
13
}
14
return hash.digest('hex');
15
}
16
17