mirror of openzeppelin-contracts
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
openzeppelin-contracts/test/helpers/hashMessage.js

8 lines
392 B

import utils from 'ethereumjs-util';
// Hash and add same prefix to the hash that testrpc use.
module.exports = function(message) {
const messageHex = new Buffer(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])) );
};