Skip to content

Commit

Permalink
Explicitly set default encoding in createHash()
Browse files Browse the repository at this point in the history
Up until now, the default encoding for this is `binary`, but
this is scheduled to change in Node 8. Since this module is
currently always passing string input to the `Hash` object,
it needs to account for that.

A better fix would likely involve dropping all strings handling
and treating binary data using Buffer objects, but I kept
this change minimal to avoid any breakage.

Refs: nodejs/node#8611
  • Loading branch information
addaleax committed Feb 21, 2017
1 parent 82b983c commit 1b94a51
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class ChecksumValidator {
let fullPath = path.resolve(baseDir, filename)
debug(`Reading file with "${this.encoding(binary)}" encoding`)
let stream = fs.createReadStream(fullPath, {encoding: this.encoding(binary)})
let hasher = crypto.createHash(this.algorithm)
let hasher = crypto.createHash(this.algorithm, {defaultEncoding: 'binary'})
hasher.on('readable', () => {
let data = hasher.read()
if (data) {
Expand Down

0 comments on commit 1b94a51

Please sign in to comment.