Skip to content

Instantly share code, notes, and snippets.

@hisasann
Created February 16, 2019 21:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hisasann/42cc85ac73361849244cb6046e3bc0bd to your computer and use it in GitHub Desktop.
Save hisasann/42cc85ac73361849244cb6046e3bc0bd to your computer and use it in GitHub Desktop.
ファイルから sha1 のハッシュ値を計算するコード
'use strict'
const crypto = require('crypto');
const fs = require('fs');
const shasum = crypto.createHash('sha1');
const app_a = __dirname + '/path/to/file.txt';
fs.readFile(app_a, (err, data) => {
shasum.update(data);
console.log(app_a, shasum.digest('hex'));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment