From 7f35240a5ceb7d89c5a72c1297b56a8e4031eaac Mon Sep 17 00:00:00 2001 From: Brian C Date: Tue, 13 Dec 2016 11:51:36 -0600 Subject: [PATCH] Fix for utf-8 characters in md5 passwords (#1183) This is the same fix as supplied in 1178 but includes a test. Closes #1178 --- lib/client.js | 2 +- test/unit/client/md5-password-tests.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/client.js b/lib/client.js index 54ab017..770f353 100644 --- a/lib/client.js +++ b/lib/client.js @@ -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 diff --git a/test/unit/client/md5-password-tests.js b/test/unit/client/md5-password-tests.js index bd5ca46..3c54036 100644 --- a/test/unit/client/md5-password-tests.js +++ b/test/unit/client/md5-password-tests.js @@ -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'); });