Skip to content

Commit

Permalink
Fix for utf-8 characters in md5 passwords (#1183)
Browse files Browse the repository at this point in the history
This is the same fix as supplied in 1178 but includes a test.

Closes #1178
  • Loading branch information
brianc authored Dec 13, 2016
1 parent 981960b commit 7f35240
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ Client.prototype.end = function(cb) {
};

Client.md5 = function(string) {
return crypto.createHash('md5').update(string).digest('hex');
return crypto.createHash('md5').update(string, 'utf-8').digest('hex');
};

// expose a Query constructor
Expand Down
3 changes: 3 additions & 0 deletions test/unit/client/md5-password-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@ test('md5 authentication', function() {
.addCString(password).join(true,'p'));
});
});
});

test('md5 of utf-8 strings', function() {
assert.equal(Client.md5('😊'), '5deda34cd95f304948d2bc1b4a62c11e');
});

0 comments on commit 7f35240

Please sign in to comment.