Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
NODE.JS - How to generate file's Checksum (CRYPTO)
var fs = require('fs');
var crypto = require('crypto');
fs.readFile('file.pdf', function(err, data) {
var checksum = generateChecksum(data);
function generateChecksum(str, algorithm, encoding) {
return crypto
.createHash(algorithm || 'md5')
.update(str, 'utf8')
.digest(encoding || 'hex');
Copy link

djuretic commented Sep 28, 2018

Thanks! It worked for me

Copy link

rodrigoagostin commented Jan 20, 2020

nice man!

Copy link

embarq commented Jun 2, 2020

Thanks a lot 🌮

Copy link

gurdiga commented Jul 1, 2021

Thank you! 🤓

@github — I miss a 👍 button for gists. 🙃

Copy link

Disorrder commented Sep 13, 2021

Neat. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment