eth-crypto
Version:
Cryptographic functions for ethereum and how to use them with web3 and solidity
22 lines (18 loc) • 474 B
JavaScript
import {
solidityPackedKeccak256
} from 'ethers';
export function keccak256(params) {
const types = [];
const values = [];
if (!Array.isArray(params)) {
types.push('string');
values.push(params);
} else {
params.forEach(p => {
types.push(p.type);
values.push(p.value);
});
}
return solidityPackedKeccak256(types, values);
}
export const SIGN_PREFIX = '\x19Ethereum Signed Message:\n32';