randomBytes

Generates an array of length pseudo-random bytes of cryptographic quality.

randomByteslengthbytes

nametypedescription

length

Integer

Length of the desired output, in bytes.

bytes

Promise for a Uint8Array

Promise that resolves to an array of length pseudo-random bytes.

Defaults to the TweetNaCl.js randomBytes implementation, which selects the underlying interface most appropriate for a given environment. When such an interface cannot be accessed, this function throws.

randomBytes is used internally to generate keys and nonces. You may replace randomBytes when instantiating confidential.

Warning Use caution when replacing randomBytes. Inadequate sources of psuedo-randomness will compromise your encryption.

randomBytes returns a promise to support possibly asynchronous operation.

Example

import {confidential} from "panda-confidential"
{randomBytes} = confidential()

bytes = await randomBytes 32