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.
20 lines
538 B
20 lines
538 B
// this file is ported from 'ether.js' and done some fixes
|
|
import * as sha3 from 'js-sha3';
|
|
|
|
import { arrayify, Arrayish } from './bytes';
|
|
|
|
export function keccak256(data: Arrayish): string {
|
|
const arrayified = arrayify(data);
|
|
if (arrayified) {
|
|
return '0x' + sha3.keccak_256(arrayified);
|
|
}
|
|
throw new Error('arrayify failed');
|
|
}
|
|
|
|
export function sha3_256(data: Arrayish): string {
|
|
const arrayified = arrayify(data);
|
|
if (arrayified) {
|
|
return '0x' + sha3.sha3_256(arrayified);
|
|
}
|
|
throw new Error('arrayify failed');
|
|
}
|
|
|