MCPcopy Create free account
hub / github.com/di-sukharev/opencommit / computeHash

Function computeHash

src/modules/commitlint/crypto.ts:3–15  ·  view source on GitHub ↗
(
  content: string,
  algorithm: string = 'sha256'
)

Source from the content-addressed store, hash-verified

1import crypto from 'crypto';
2
3export const computeHash = async (
4 content: string,
5 algorithm: string = 'sha256'
6): Promise<string> => {
7 try {
8 const hash = crypto.createHash(algorithm);
9 hash.update(content);
10 return hash.digest('hex');
11 } catch (error) {
12 console.error('Error while computing hash:', error);
13 throw error;
14 }
15};

Callers 1

Calls 2

updateMethod · 0.80
errorMethod · 0.45

Tested by

no test coverage detected