How to use md5-file - 10 common examples

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 ibi-group / datatools-ui / __tests__ / end-to-end.js View on Github external
const files = await fs.readdir(downloadsDir)
      let feedVersionDownloadFile = ''
      // assume that this file will be the only one matching the feed source ID
      for (const file of files) {
        if (file.indexOf(feedSourceId.replace(/:/g, '')) > -1) {
          feedVersionDownloadFile = file
          break
        }
      }
      if (!feedVersionDownloadFile) {
        throw new Error('Feed Version gtfs file not found in Downloads folder!')
      }

      // verify that file has same hash as gtfs file that was uploaded
      const filePath = path.join(downloadsDir, feedVersionDownloadFile)
      expect(await md5File(filePath)).toEqual(await md5File(gtfsUploadFile))

      // delete file
      await fs.remove(filePath)
    }, defaultTestTimeout)
github DefinitelyTyped / DefinitelyTyped / types / md5-file / md5-file-tests.ts View on Github external
import * as md5 from "md5-file";
import * as md5Promise from "md5-file/promise";

// $ExpectType void
md5("test.txt", (err, hash) => {
	return;
});

// $ExpectType string
md5.sync("text.txt");

// $ExpectType Promise
md5Promise("test.txt");

// $ExpectType string
md5Promise.sync("text.txt");
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 ashmind / SharpLab / source / WebApp / build.ts View on Github external
const html = task('html', async () => {
    const iconDataUrl = await getIconDataUrl();
    const templates = await getCombinedTemplates();
    const [jsHash, cssHash] = await parallel(
        md5File('wwwroot/app.min.js'),
        md5File('wwwroot/app.min.css')
    );
    // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
    let html = (await jetpack.readAsync(paths.from.html))!;
    html = html
        .replace('{build:js}', 'app.min.js?' + jsHash)
        .replace('{build:css}', 'app.min.css?' + cssHash)
        .replace('{build:templates}', templates)
        .replace('{build:favicon-svg}', iconDataUrl);
    html = htmlMinifier.minify(html, { collapseWhitespace: true });
    await jetpack.writeAsync(paths.to.html, html);
}, {
    watch: [
github joelday / papyrus-lang / src / papyrus-lang-vscode / src / debugger / DebugSupportInstallService.ts View on Github external
return DebugSupportInstallState.installed;
        }

        // For clarity and consistency, the plugin is being renamed to end with Fallout4.dll
        // This handles the case where the old version is installed.
        const legacyInstalledPluginPath = await this.getPluginInstallPath(game, true);
        if (game === PapyrusGame.fallout4 && (await exists(legacyInstalledPluginPath))) {
            return DebugSupportInstallState.incorrectVersion;
        }

        const installedPluginPath = await this.getPluginInstallPath(game, false);
        if (!(await exists(installedPluginPath))) {
            return DebugSupportInstallState.notInstalled;
        }

        const installedHash = await md5File(installedPluginPath);
        const bundledHash = await md5File(this.getBundledPluginPath(game));

        if (installedHash !== bundledHash) {
            return DebugSupportInstallState.incorrectVersion;
        }

        return DebugSupportInstallState.installed;
    }
github ashmind / SharpLab / source / WebApp / build.ts View on Github external
const html = task('html', async () => {
    const iconDataUrl = await getIconDataUrl();
    const templates = await getCombinedTemplates();
    const [jsHash, cssHash] = await parallel(
        md5File('wwwroot/app.min.js'),
        md5File('wwwroot/app.min.css')
    );
    // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
    let html = (await jetpack.readAsync(paths.from.html))!;
    html = html
        .replace('{build:js}', 'app.min.js?' + jsHash)
        .replace('{build:css}', 'app.min.css?' + cssHash)
        .replace('{build:templates}', templates)
        .replace('{build:favicon-svg}', iconDataUrl);
    html = htmlMinifier.minify(html, { collapseWhitespace: true });
    await jetpack.writeAsync(paths.to.html, html);
}, {
    watch: [
github joelday / papyrus-lang / src / papyrus-lang-vscode / src / debugger / DebugSupportInstallService.ts View on Github external
}

        // For clarity and consistency, the plugin is being renamed to end with Fallout4.dll
        // This handles the case where the old version is installed.
        const legacyInstalledPluginPath = await this.getPluginInstallPath(game, true);
        if (game === PapyrusGame.fallout4 && (await exists(legacyInstalledPluginPath))) {
            return DebugSupportInstallState.incorrectVersion;
        }

        const installedPluginPath = await this.getPluginInstallPath(game, false);
        if (!(await exists(installedPluginPath))) {
            return DebugSupportInstallState.notInstalled;
        }

        const installedHash = await md5File(installedPluginPath);
        const bundledHash = await md5File(this.getBundledPluginPath(game));

        if (installedHash !== bundledHash) {
            return DebugSupportInstallState.incorrectVersion;
        }

        return DebugSupportInstallState.installed;
    }

md5-file

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

MIT
Latest version published 5 years ago

Package Health Score

71 / 100
Full package analysis