diff options
author | Dan Finlay <dan@danfinlay.com> | 2017-03-07 09:19:36 +0800 |
---|---|---|
committer | Dan Finlay <dan@danfinlay.com> | 2017-03-07 09:20:57 +0800 |
commit | cdcd1b1e8b9219ad2f5b6f029e3f0bc48e879455 (patch) | |
tree | 0da69b786966b79578ce817dfeaa66ee170309d5 | |
parent | 2acf991b67bc42fb904ff77af6ff6a7ca3a683fd (diff) | |
download | tangerine-wallet-browser-cdcd1b1e8b9219ad2f5b6f029e3f0bc48e879455.tar tangerine-wallet-browser-cdcd1b1e8b9219ad2f5b6f029e3f0bc48e879455.tar.gz tangerine-wallet-browser-cdcd1b1e8b9219ad2f5b6f029e3f0bc48e879455.tar.bz2 tangerine-wallet-browser-cdcd1b1e8b9219ad2f5b6f029e3f0bc48e879455.tar.lz tangerine-wallet-browser-cdcd1b1e8b9219ad2f5b6f029e3f0bc48e879455.tar.xz tangerine-wallet-browser-cdcd1b1e8b9219ad2f5b6f029e3f0bc48e879455.tar.zst tangerine-wallet-browser-cdcd1b1e8b9219ad2f5b6f029e3f0bc48e879455.zip |
Fix hex encoding of message to create valid hex strings
-rw-r--r-- | app/scripts/lib/personal-message-manager.js | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/app/scripts/lib/personal-message-manager.js b/app/scripts/lib/personal-message-manager.js index bbc978446..17c9739de 100644 --- a/app/scripts/lib/personal-message-manager.js +++ b/app/scripts/lib/personal-message-manager.js @@ -118,8 +118,21 @@ module.exports = class PersonalMessageManager extends EventEmitter{ log.debug(`Message was not hex encoded, interpreting as utf8.`) } - return ethUtil.bufferToHex(new Buffer(data, 'utf8')) + return hexEncode(data) + } + + hexEncode(text){ + var hex, i + + var result = '' + for (i = 0; i < text.length; i++) { + hex = text.charCodeAt(i).toString(16) + result += ('000'+hex).slice(-4) + } + return '0x' + result } } + + |