Commit 0ba6cd5e authored by yann300's avatar yann300

normalize hex

parent 5ef4a06f
...@@ -133,6 +133,9 @@ module.exports = { ...@@ -133,6 +133,9 @@ module.exports = {
* @return {Object} - return sha3ied value * @return {Object} - return sha3ied value
*/ */
sha3_256: function (value) { sha3_256: function (value) {
if (typeof value === 'string' && !value.startsWith('0x')) {
value = '0x' + value
}
var ret = ethutil.bufferToHex(ethutil.setLengthLeft(value, 32)) var ret = ethutil.bufferToHex(ethutil.setLengthLeft(value, 32))
ret = ethutil.sha3(ret) ret = ethutil.sha3(ret)
return ethutil.bufferToHex(ret) return ethutil.bufferToHex(ret)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment