overleaf-cep/services/history-v1/storage/lib/content_hash.js
Eric Mc Sween ce4c8a4e47 Merge pull request #23398 from overleaf/em-log-doc-hash-mismatches
Validate content hashes in history (log only)

GitOrigin-RevId: ed772fc4e4d0aa9e980f9693a759647bd937e13a
2025-02-07 09:05:59 +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 }