Successfully tested

This commit is contained in:
Aniket
2018-03-13 16:30:25 +05:30
committed by Aniket-Engg
parent fb713432f3
commit e51c5e01c1
2 changed files with 70 additions and 0 deletions

View File

@ -0,0 +1,8 @@
import utils from 'ethereumjs-util';
// Hash and add same prefix to the hash that testrpc use.
module.exports = function (message) {
const messageHex = Buffer.from(utils.sha3(message).toString('hex'), 'hex');
const prefix = utils.toBuffer('\u0019Ethereum Signed Message:\n' + messageHex.length.toString());
return utils.bufferToHex(utils.sha3(Buffer.concat([prefix, messageHex])));
};