backup_filehash.js 496 B

123456789101112131415
  1. const crypto = require('crypto')
  2. /**
  3. * Derive a file's ID from it's filename and domain.
  4. * @deprecated use backup3.js -> getFileID(file, domain) instead.
  5. *
  6. * @param {string} file the path to the file in the domain
  7. * @param {string=} domain (optional) the file's domain. Default: HomeDomain
  8. */
  9. module.exports = function fileHash (file, domain) {
  10. domain = domain || 'HomeDomain'
  11. let shasum = crypto.createHash('sha1')
  12. shasum.update(`${domain}-${file}`)
  13. return shasum.digest('hex')
  14. }