content_hash.js 347 B

123456789101112131415161718
  1. // @ts-check
  2. const { createHash } = require('node:crypto')
  3. /**
  4. * Compute a SHA-1 hash of the content
  5. *
  6. * This is used to validate incoming updates.
  7. *
  8. * @param {string} content
  9. */
  10. function getContentHash(content) {
  11. const hash = createHash('sha-1')
  12. hash.update(content)
  13. return hash.digest('hex')
  14. }
  15. module.exports = { getContentHash }