( content: string, algorithm: string = 'sha256' )
| 1 | import crypto from 'crypto'; |
| 2 | |
| 3 | export 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 | }; |
no test coverage detected