mirror of
https://github.com/di-sukharev/opencommit.git
synced 2026-04-20 03:02:51 -04:00
16 lines
352 B
TypeScript
16 lines
352 B
TypeScript
import crypto from 'crypto';
|
|
|
|
export const computeHash = async (
|
|
content: string,
|
|
algorithm: string = 'sha256'
|
|
): Promise<string> => {
|
|
try {
|
|
const hash = crypto.createHash(algorithm);
|
|
hash.update(content);
|
|
return hash.digest('hex');
|
|
} catch (error) {
|
|
console.error('Error while computing hash:', error);
|
|
throw error;
|
|
}
|
|
};
|