Skip to content

Commit 1b94a51

Browse files
committed
Explicitly set default encoding in createHash()
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
1 parent 82b983c commit 1b94a51

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class ChecksumValidator {
138138
let fullPath = path.resolve(baseDir, filename)
139139
debug(`Reading file with "${this.encoding(binary)}" encoding`)
140140
let stream = fs.createReadStream(fullPath, {encoding: this.encoding(binary)})
141-
let hasher = crypto.createHash(this.algorithm)
141+
let hasher = crypto.createHash(this.algorithm, {defaultEncoding: 'binary'})
142142
hasher.on('readable', () => {
143143
let data = hasher.read()
144144
if (data) {

0 commit comments

Comments
 (0)