* Use js-sha3 instead of keccak * Remove exposed toBuffer from util-crypto * Add definiton for js-sha3 * Remove Buffer from docs * Cleanup crypto hashing * Cleanup interface
1.2 KiB
1.2 KiB
random
Returns a sequence of secure random bytes in a variety of formats
- randomAsHex Creates a hex string filled with random bytes.
- randomAsNumber Creates a random number from random bytes.
- randomAsU8a Creates a Uint8Array filled with random bytes.
randomAsHex
Creates a hex string filled with random bytes.
randomAsHex (length?: number = 32): string
Returns a hex string with the specified (optional) length filled with random bytes.
import { randomAsHex } from '@polkadot/util-crypto';
randomAsHex() // => 0x...
randomAsNumber
Creates a random number from random bytes.
randomAsNumber (): number
Returns a random number generated from the secure bytes.
import { randomAsNumber } from '@polkadot/util-crypto';
randomAsNumber() // => <random number>
randomAsU8a
Creates a Uint8Array filled with random bytes.
randomAsU8a (length?: number = 32): Uint8Array
Returns a Uint8Array with the specified (optional) length filled with random bytes.
import { randomAsU8a } from '@polkadot/util-crypto';
randomAsU8s() // => Uint8Array([...])