hashMessage.js 392 B

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