* 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
1.4 KiB
1.4 KiB
xxhash
Create XXHash values as BN, hex & number output
- xxhashAsBn Creates a xxhash BN from the input.
- xxhashAsHex Creates a xxhash hex from the input.
- xxhashAsNumber Creates a xxhash number from the input.
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