Files
common/packages/util-crypto/docs/xxhash.md
T
Jaco Greeff b5c5734c7c Add Blake2s & XXHash utility functions (#66)
* Initial split of util & util-crypto

* Add initial XXHash version

* Blake2s wit tests & documentation

* Add sha512 (from NaCl)

* Add randomBytes (from NaCl)

* Flow fixes

* Update documentation

* Update latest @polkadot/dev
2018-01-25 14:13:43 +01:00

1.4 KiB

xxhash

Create XXHash values as BN, hex & number output

xxhashAsBn

Creates a xxhash BN from the input.

xxhashAsBn (data: Buffer | Uint8Array | string, seed: number): BN

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

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

xxhashAsBn('abcd', 0xabcd)) // => new BN(0xcda8fae4)

xxhashAsHex

Creates a xxhash hex from the input.

xxhashAsHex (data: Buffer | Uint8Array | string, seed: number): string

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

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

xxhashAsHex('abcd', 0xabcd)) // => 0xcda8fae4

xxhashAsNumber

Creates a xxhash number from the input.

xxhashAsNumber (data: Buffer | Uint8Array | string, seed: number): number

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

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

xxhashAsNumber('abcd', 0xabcd)) // => 0xcda8fae4