mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Fix hex encoding of message to create valid hex strings
This commit is contained in:
parent
2acf991b67
commit
cdcd1b1e8b
@ -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…
Reference in New Issue
Block a user