How to use the sha3.Keccak function in sha3

To help you get started, we’ve selected a few sha3 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github iotexproject / iotex-antenna / src / crypto / hash.ts View on Github external
export function hash256b(input: string | Buffer | Uint8Array): Buffer {
  const k = new Keccak(256);
  // @ts-ignore
  k.update(Buffer.from(input));
  return k.digest();
}
github hyperledger / burrow / js / src / lib / contracts / function.ts View on Github external
payload.setFee(0);
  const code = Buffer.from(data, 'hex');
  // if we are deploying and it looks like wasm, it must be wasm. Note that
  // evm opcode 0 is stop, so this would not make any sense.
  const wasm_magic = Buffer.from('\0asm');
  if (!address && !Buffer.compare(code.slice(0, 4), wasm_magic)) {
    payload.setWasm(code);
  } else {
    payload.setData(code);
  }
  // If address is null then we are creating a new contract, if we have the deployedBytecode then send it with the ABI
  if (!address && contract.code.deployedBytecode) {
    const meta = new ContractMeta()
    // TODO: document/formalise the expected structure of the contract metadata
    meta.setMeta(JSON.stringify({ Abi: contract.abi }))
    const codeHash = (new Keccak(256)).update(contract.code.deployedBytecode, "hex").digest()
    meta.setCodehash(codeHash)
    payload.setContractmetaList([meta])
  }

  return payload
}
github iotexproject / iotex-antenna / lib / crypto / hash.js View on Github external
function hash256b(input) {
  const k = new _sha.Keccak(256); // @ts-ignore

  k.update(Buffer.from(input));
  return k.digest();
}
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jcnlwdG8vaGFzaC50cyJdLCJuYW1lcyI6WyJoYXNoMTYwYiIsImlucHV0IiwiZGlnZXN0IiwiaGFzaDI1NmIiLCJzbGljZSIsImsiLCJLZWNjYWsiLCJ1cGRhdGUiLCJCdWZmZXIiLCJmcm9tIl0sIm1hcHBpbmdzIjoiOzs7Ozs7OztBQUNBOztBQURBO0FBR0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQU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uc3QgZGlnZXN0ID0gaGFzaDI1NmIoaW5wdXQpO1xuICByZXR1cm4gZGlnZXN0LnNsaWNlKDEyKTtcbn1cblxuZXhwb3J0IGZ1bmN0aW9uIGhhc2gyNTZiKGlucHV0OiBzdHJpbmcgfCBCdWZmZXIgfCBVaW50OEFycmF5KTogQnVmZmVyIHtcbiAgY29uc3QgayA9IG5ldyBLZWNjYWsoMjU2KTtcbiAgLy8gQHRzLWlnbm9yZVxuICBrLnVwZGF0ZShCdWZmZXIuZnJvbShpbnB1dCkpO1xuICByZXR1cm4gay5kaWdlc3QoKTtcbn1cbiJdfQ==
github spacemeshos / app / src / services / sigs / secretkeyex.ts View on Github external
public DeriveSecretKey(i: number): SecertKeyEx {
        // newKeyRndSeed = Keccak512(chainCode, i, rndSeed).substring(0,96)
        const hash = new Keccak(384); // Keccak 384 has size is 48 bytes
        hash.update(this.chainCode);
        hash.update(i.toString());
        hash.update(this.rndSeed);
        return new SecertKeyEx(hash.digest('hex') + this.chainCode);
    }
}
github hyperledger / burrow / js / src / solts / lib / solidity.ts View on Github external
export function sha3(str: string): string {
  const hash = new Keccak(256).update(str);
  return hash.digest('hex').toUpperCase();
}
github hyperledger / burrow / js / src / contracts / call.ts View on Github external
export function getContractMetaFromBytecode(abi: ABI, deployedBytecode: string): ContractMeta {
  const hasher = new Keccak(256);
  const codeHash = hasher.update(deployedBytecode, 'hex').digest();
  return getContractMeta(abi, codeHash);
}
github hyperledger / burrow / js / src / contracts / event.ts View on Github external
function sha3(str: string) {
  return new Keccak(256).update(str).digest('hex').toUpperCase();
}

sha3

The Keccak family of hashing algorithms.

MIT
Latest version published 4 years ago

Package Health Score

53 / 100
Full package analysis