-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
AbigailDeng
authored and
AbigailDeng
committed
Mar 21, 2023
1 parent
879808c
commit c06678b
Showing
11 changed files
with
162 additions
and
393 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const createKeccakHash = require('keccak'); | ||
|
||
const keccak = bits => str => { | ||
let msg; | ||
if (str.slice(0, 2) === '0x') { | ||
msg = []; | ||
for (let i = 2, l = str.length; i < l; i += 2) { | ||
msg.push(parseInt(str.slice(i, i + 2), 16)); | ||
} | ||
msg = Buffer.from(msg); | ||
} else { | ||
msg = str; | ||
} | ||
const instance = createKeccakHash(`keccak${bits}`); | ||
return `0x${instance.update(msg).digest('hex')}`; | ||
}; | ||
|
||
export const keccak256 = keccak(256); | ||
export const keccak512 = keccak(512); | ||
export const keccak256s = keccak(256); | ||
export const keccak512s = keccak(512); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.