diff --git a/lib/tools.js b/lib/tools.js index 600bf7a0f..6f1959963 100644 --- a/lib/tools.js +++ b/lib/tools.js @@ -46,8 +46,10 @@ function encryptPhrase(password, phrase, callback) { encrypted += data.toString('hex'); } }); - cipher.on('end', () => callback(encrypted)); - + cipher.on('end', () => { + callback(encrypted); + }); + cipher.write(phrase); cipher.end(); } @@ -68,7 +70,9 @@ function decryptPhrase(password, data, callback) { console.error(`Cannot decode secret: ${error}`); callback(null); }); - decipher.on('end', function () callback(decrypted)); + decipher.on('end', function () { + callback(decrypted); + }); decipher.write(data, 'hex'); decipher.end();