Skip to content

Commit 7f35240

Browse files
authored
Fix for utf-8 characters in md5 passwords (brianc#1183)
This is the same fix as supplied in 1178 but includes a test. Closes brianc#1178
1 parent 981960b commit 7f35240

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

lib/client.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ Client.prototype.end = function(cb) {
344344
};
345345

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

350350
// expose a Query constructor

test/unit/client/md5-password-tests.js

+3
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,8 @@ test('md5 authentication', function() {
1717
.addCString(password).join(true,'p'));
1818
});
1919
});
20+
});
2021

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

0 commit comments

Comments
 (0)