Fix hex encoding of message to create valid hex strings

feature/default_network_editable
Dan Finlay 8 years ago
parent 2acf991b67
commit cdcd1b1e8b
  1. 15
      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
}
}

Loading…
Cancel
Save