added examples

This commit is contained in:
Aniket-Engg
2018-12-21 16:50:16 +05:30
parent a781955434
commit c3c5d767ff
7 changed files with 128 additions and 162 deletions

View File

@ -1,8 +0,0 @@
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])));
};