How to use checksum - 10 common examples

To help you get started, we’ve selected a few checksum examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github xtremespb / taracotjs / bin / .production.js View on Github external
core_output.on('close', function() {
                            checksum.file(modules_dir + '/taracot_core.zip_', function(err, core_sum) {
                                async.eachSeries(modules, function(module, callback) {
                                    // if (!module.match(/^billing_/)) {
                                    console.log("Re-creating temp dir...");
                                    fs.removeSync(modules_dir_tmp);
                                    fs.ensureDir(modules_dir_tmp);
                                    console.log("Copying " + module + " files...");
                                    fs.copySync(production_dir + '/modules/' + module, modules_dir_tmp + '/' + module);
                                    var core_archive = archiver('zip'),
                                        core_output = fs.createWriteStream(modules_dir + '/taracot_' + module + '.zip');
                                    core_archive.pipe(core_output);
                                    console.log("Creating " + module + " update ZIP file...");
                                    core_archive.bulk([{
                                        expand: true,
                                        cwd: modules_dir_tmp,
                                        src: ['./**']
                                    }]);
github bionode / bionode-watermill / lib / resolvers.js View on Github external
const checksummer = (resolved) => {
  if (!(resolved instanceof Array)) {
    resolved = [resolved]
  }

  console.log(tab(1) + 'Now going to generate checksums on resolved files')

  for (let obj of resolved) {
    if (obj.file) {
      if (!Array.isArray(obj.file)) {
        obj.file = [obj.file]
      }
      for (let filePath of obj.file) {
        // TODO handle errors better
        checksum.file(filePath, (err, sum) => {
          if (err) {
            console.log('ERROR: ', err)
            return
          }

          let stats
          try {
            stats = fs.statSync(filePath)
          } catch(err) {
            console.log('ERROR: ', err)
          }

          const objDetails = {}

          objDetails[filePath] = {
            hash: sum,
github ubports / ubports-installer / src / utils.js View on Github external
fs.access(path.join(file.path, path.basename(file.url)), err => {
      if (err) {
        reject(err);
      } else {
        if (!file.checksum) {
          // No checksum so return true;
          resolve();
          return;
        } else {
          checksum.file(
            path.join(file.path, path.basename(file.url)),
            {
              algorithm: "sha256"
            },
            function(err, sum) {
              utils.log.debug(
                "checked: " + path.basename(file.url),
                sum === file.checksum
              );
              if (sum === file.checksum) {
                resolve();
              } else {
                reject(
                  new Error(
                    "checksum mismatch: calculated " +
                      sum +
github jaruba / PowderWeb / server / streams.js View on Github external
}).catch(fail)
            }

            if (torrentData && torrentData.infoHash) {

                const iHash = torrentData.infoHash
                const appDataFastResume = path.join(fastResumeDir, iHash + '.fastresume')

                const removeFastResume = () => {
                    fs.unlink(appDataFastResume, () => {
                        startTorrent()
                    })
                }

                if (fs.existsSync(appDataFastResume)) {
                    checksum.file(appDataFastResume, function (err, sum) {
                       if (!err && sum) {
                           const fastBook = fastresumebook.get(iHash)

                           if (fastBook && fastBook.sum) {
                            if (fastBook.sum == sum) {
                                // checksum of fast resume file correct, continue
                                startTorrent()
                            } else {
                                // checksum incorrect, remove
                                removeFastResume()
                            }
                           } else {
                               // checksum incorrect, remove
                               removeFastResume()
                           }
                       } else {
github desktop / dugite / script / downloader.ts View on Github external
return new Promise((resolve, reject) => {
    checksum.file(file, { algorithm: 'sha256' }, (_: any, hash: string) => {
      if (hash !== expected) {
        console.log(`checksum failed: got '${hash}' but expected '${expected}'`)
      }
      resolve(hash === expected)
    })
  })
}
github xtremespb / taracotjs / bin / .production.js View on Github external
async.eachSeries(zip_files, function(file, callback) {
                                            checksum.file(file, function(err, sum) {
                                                if (err || !sum) return callback(err || "Failed to get checksum for " + file);
                                                taracot_info[modules[cnt]].checksum = sum;
                                                cnt++;
                                                callback();
                                            });
                                        }, function(err) {
                                            if (err) return console.log(err);
github willrstern / docker-cloud-nginx-load-balancing / lib / reload-nginx.js View on Github external
checksum.file(configFileName, (err, sum) => {
      if (sum !== checksum(newNginxConf)) {
        reloadNginxConfig(newNginxConf)
      } else {
        console.log("Nginx config was unchanged");
      }
    });
  }
github mweststrate / relative-deps / index.js View on Github external
return await new Promise((resolve, reject) => {
    checksum.file(file, (error, hash) => {
      if (error) reject(error)
      else resolve(hash)
    })
  })
}
github Pierce01 / MinecraftLauncher-core / components / handler.js View on Github external
return new Promise(resolve => {
            checksum.file(file, (err, sum) => resolve(hash === sum));
        });
    }

checksum

Checksum utility for node

MIT
Latest version published 3 years ago

Package Health Score

54 / 100
Full package analysis

Popular checksum functions