How to use the md5-file.sync function in md5-file

To help you get started, we’ve selected a few md5-file 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 iExecBlockchainComputing / iexec-stack / src / main / resources / javascript / client / xwhep-js-client.js View on Github external
const uploadDataPath = `${PATH_UPLOADDATA}/${dataUid}`;
      const options = {
        hostname,
        port : port,
        path : `${PATH_UPLOADDATA}/${dataUid}${creds}`,
        method : 'POST',
        protocol : 'https:',
        rejectUnauthorized: false
      };
      console.log(`uploadData(${dataUid}) : ${options.hostname}:${options.port}${options.path}`);

      const stats = fs.statSync(dataPath);
//      console.log(stats);
      const dataSize = stats['size'];

      const dataMD5 = md5File.sync(dataPath);

//      console.log('uploadData DATAUID ', dataUid);
//      console.log('uploadData DATAMD5SUM ', dataMD5);
//      console.log('uploadData DATASIZE ', dataSize);
//      console.log('uploadData DATAFILE ', dataPath);

      const dataForm = new FormData();
      dataForm.append('DATAUID', dataUid);
      dataForm.append('DATAMD5SUM', dataMD5);
      dataForm.append('DATASIZE', dataSize);
      dataForm.append('DATAFILE', fs.createReadStream(dataPath));
      dataForm.submit(options, function(err, res) {
    	if (err) {
           reject('uploadData error ' + err);
           return;
        }
github material-components / material-components-site-generator / scripts / lib / rewrite-local-links.js View on Github external
reporter.linkWarning(href, file.path, 'Potentially broken image link detected.');
      return href;
    }

    reporter.brokenLink(href, file.path);
    throw new Error('Broken link detected. Stopping build.')
  }

  // If we're dealing with an asset, give it a name that won't collide, and copy
  // it to a central directory.
  // TODO(shyndman): This feels out of place here. These methods are about
  // rewriting links, not copying assets.
  if (patterns.newAssetPathPattern().test(srcLocalUrl.pathname)) {
    const destLocalPath = path.join(
        CONTENT_ASSETS_PATH,
        md5File.sync(srcLocalUrl.pathname) +
        path.extname(srcLocalUrl.pathname));
    const destAssetHref = path.join(site.siteRoot || '/', destLocalPath);
    fs.copySync(srcLocalUrl.pathname, path.join(BuildDir.STAGE, destLocalPath));
    return destAssetHref;
  }

  const pathWithReadme = path.join(srcLocalUrl.pathname, 'README.md');
  if (srcPathsToFiles.has(pathWithReadme)) {
    srcLocalUrl.pathname = pathWithReadme;
  }

  // If the specified path has an associated markdown file in the site, rewrite
  // the link to point to it, including the search and hash.
  if (srcPathsToFiles.has(srcLocalUrl.pathname)) {
    const destFile = srcPathsToFiles.get(srcLocalUrl.pathname);
    const destLocalUrl = url.parse(
github ashmind / SharpLab / source / WebApp / gulpfile.js View on Github external
gulp.task('html', () => {
    const roslynVersion = getRoslynVersion();
    const faviconSvg = fs.readFileSync('favicon.svg', 'utf8');
    // http://codepen.io/jakob-e/pen/doMoML
    const faviconSvgUrlSafe = faviconSvg
        .replace(/"/g, '\'')
        .replace(/%/g, '%25')
        .replace(/#/g, '%23')
        .replace(/{/g, '%7B')
        .replace(/}/g, '%7D')
        .replace(//g, '%3E')
        .replace(/\s+/g,' ');
    const jsHash  = md5File.sync('wwwroot/app.min.js');
    const cssHash = md5File.sync('wwwroot/app.min.css');

    return gulp
        .src('./index.html')
        .pipe(g.htmlReplace({ js: 'app.min.js?' + jsHash, css: 'app.min.css?' + cssHash })) // eslint-disable-line prefer-template
        .pipe(g.replace('{build:favicon-svg}', faviconSvgUrlSafe))
        .pipe(g.replace('{build:roslyn-version}', roslynVersion))
        .pipe(gulp.dest('wwwroot'));
});
github tkalfigo / dotenvenc / index.js View on Github external
function encrypt(passwd) {
  let cipher = crypto.createCipher(algor, passwd),
    decryptedFileLocation = findFileLocation(DECRYPTED_FILENAME),
    decryptedFileFullPath = decryptedFileLocation + DECRYPTED_FILENAME,
    encryptedFileFullPath = decryptedFileLocation + ENCRYPTED_FILENAME, // we write encrypted file at same location as where we found decrypted file
    encBuff;
  if (!passwd) {
    throw new Error('encryption requires a password');
  }
  encBuff = Buffer.concat([cipher.update(readFile(decryptedFileFullPath)), cipher.final()]);
  writeFile(encryptedFileFullPath, encBuff);
  return md5FileSync(encryptedFileFullPath);
}
github feup-infolab / dendro / test / mockdata / files / keywords / RoutePlanning.js View on Github external
const path = require("path");
const rlequire = require("rlequire");
const Config = rlequire("dendro", "src/models/meta/config.js").Config;
const md5File = require("md5-file");

module.exports = {
    md5: md5File.sync(rlequire.absPathInApp("dendro", "test/mockdata/keywords/vehiclesimulation/RoutePlanning.pdf")),
    name: "RoutePlanning.pdf",
    extension: "pdf",
    location: rlequire.absPathInApp("dendro", "test/mockdata/keywords/vehiclesimulation/RoutePlanning.pdf"),
    metadata: [{
        prefix: "nie",
        shortName: "plainTextContent",
        value: "nie:isLogicalPartOf Pn Dn 280mm \"DCB Base Data\" 120 Dn-1 dcb:initialCrackLength dcterms:title dcb:specimenWidth dcterms:isReferencedBy Fn 120 dcterms:title dcb:specimenWidth dcterms:isVersionOf Added property instance 01/01/2014 ^^xsd:date dcterms:created 01/01/2014 ^^xsd:date dcterms:modi ed Changed modi cation timestamp Revision creation timestamp Un dcterms:creator Current dataset version Past Revisions ddr:pertainsTo Change recording C dcb:initial CrackLen gth ddr:changedDescriptor \"add\" ddr:operation \"DCB Base Data\""
    },
    {
        prefix: "dcterms",
        shortName: "abstract",
        value: "This is a pdf file."
    },
    {
        prefix: "dcterms",
        shortName: "title",
github feup-infolab / dendro / test / mockdata / files / keywords / doc11.js View on Github external
const path = require("path");
const rlequire = require("rlequire");
const Config = rlequire("dendro", "src/models/meta/config.js").Config;
const md5File = require("md5-file");

module.exports = {
    md5: md5File.sync(rlequire.absPathInApp("dendro", "test/mockdata/keywords/SustainableChemistry/doc11.pdf")),
    name: "BusPerformance.pdf",
    extension: "pdf",
    location: rlequire.absPathInApp("dendro", "test/mockdata/keywords/SustainableChemistry/doc11.pdf"),
    metadata: [{
        prefix: "nie",
        shortName: "plainTextContent",
        value: "nie:isLogicalPartOf Pn Dn 280mm \"DCB Base Data\" 120 Dn-1 dcb:initialCrackLength dcterms:title dcb:specimenWidth dcterms:isReferencedBy Fn 120 dcterms:title dcb:specimenWidth dcterms:isVersionOf Added property instance 01/01/2014 ^^xsd:date dcterms:created 01/01/2014 ^^xsd:date dcterms:modi ed Changed modi cation timestamp Revision creation timestamp Un dcterms:creator Current dataset version Past Revisions ddr:pertainsTo Change recording C dcb:initial CrackLen gth ddr:changedDescriptor \"add\" ddr:operation \"DCB Base Data\""
    },
    {
        prefix: "dcterms",
        shortName: "abstract",
        value: "This is a pdf file."
    },
    {
        prefix: "dcterms",
        shortName: "title",
github cloudant / nodejs-cloudant / test / stream.js View on Github external
.on('finish', function() {
              assert.equal(md5File.sync('data.json'), md5File.sync('test/fixtures/all_docs_include_docs.json'));
              fs.unlinkSync('data.json');
              mocks.done();
              done();
            });
        }
github anlix-io / flashman / controllers / device_list.js View on Github external
writeStream.on('close', ()=>{
              let md5fname = imageReleasesDir + '.' + fname.replace('.bin', '.md5');
              let binfname = imageReleasesDir + fname;
              let md5Checksum = md5File.sync(binfname);
              fs.writeFileSync(md5fname, md5Checksum);
              return resolve(true);
            });
            entry.pipe(writeStream);
github amzn / sketch-constructor / models / Bitmap / Bitmap.js View on Github external
constructor(args = {}, json) {
    super(args, json);
    if (!json) {
      const id = args.id || uuid().toUpperCase();
      Object.assign(this, Bitmap.Model, {
        do_objectID: id,
        name: args.name || id,
        frame: new Rect(args.frame),
        style: new Style(args.style),
        layers: args.layers || [],
      });
      const fileHash = md5File.sync(args.filePath);
      this.image._ref = `images/${fileHash}.png`;
      fs.ensureDirSync(STORAGE_IMG_DIR);
      fs.copyFileSync(args.filePath, `${STORAGE_DIR}/${this.image._ref}`);
    }

    return this;
  }
}

md5-file

Get the MD5-sum of a given file, with low memory usage, even on huge files.

MIT
Latest version published 4 years ago

Package Health Score

71 / 100
Full package analysis