Files
common/packages/util-crypto/docs/keccak.md
T
Jaco Greeff feef48b44c Uint8Array outputs from crypto (#74)
* Uint8Array outputs from crypto

* Small typos

* Update documentation
2018-02-07 11:22:17 +01:00

1.7 KiB

keccak

Create Keccak256 values as hex, string, Buffer & Uint8Array output

keccakAsBuffer

Creates a keccak Buffer from the input.

keccakAsBuffer (value: Buffer | string): Buffer

From either a string or a Buffer input, create the keccak and return the result as a Buffer.

import { keccakAsBuffer } from '@polkadot/util-crypto';

console.log('asBuffer', keccakAsBuffer('123')) // => Buffer

keccakAsHex

Creates a keccak hex string from the input.

keccakAsHex (value: Buffer | string): string

From either a string or a Buffer input, create the keccak and return the result as a 0x prefixed hex string.

import { keccakAsHex } from '@polkadot/util-crypto';

console.log('asHex', keccakAsHex('123')) // => 0x...

keccakAsString

Creates a keccak string from the input.

keccakAsString (value: Buffer | string): string

From either a string or a Buffer input, create the keccak and return the result as a non-prefixed string.

import { keccakAsString } from '@polkadot/util-crypto';

console.log('asString', keccakAsString('123')) // => string

keccakAsU8a

Creates a keccak Uint8Array from the input.

keccakAsU8a (value: Buffer | string): Uint8Array

From either a string or a Buffer input, create the keccak and return the result as a Uint8Array.

import { keccakAsU8a } from '@polkadot/util-crypto';

keccakAsU8a('123') // => Uint8Array