latex-ub/services/history-v1/storage/lib/content_hash.js
2025-05-05 12:24:05 +00:00

18 lines
347 B
JavaScript

// @ts-check
const { createHash } = require('node:crypto')
/**
* Compute a SHA-1 hash of the content
*
* This is used to validate incoming updates.
*
* @param {string} content
*/
function getContentHash(content) {
const hash = createHash('sha-1')
hash.update(content)
return hash.digest('hex')
}
module.exports = { getContentHash }