Skip to content

Commit

Permalink
Create 02: Hash Message.js
Browse files Browse the repository at this point in the history
  • Loading branch information
leowvazd authored Feb 4, 2024
1 parent d7d66db commit c1b2be5
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions 02: Hash Message.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const { keccak256 } = require("ethereum-cryptography/keccak");
const { utf8ToBytes } = require("ethereum-cryptography/utils");

function hashMessage(message) {
// turn message into array of bytes
const bytes = utf8ToBytes(message);

// hash the bytes message using keccack256
const hash = keccak256(bytes);

return hash;
}

module.exports = hashMessage;

0 comments on commit c1b2be5

Please sign in to comment.