Blockchain Commons Rand TypeScript Library - v1.0.0-alpha.13
    Preparing search index...

    Interface RandomNumberGenerator

    Interface for random number generators. This is the TypeScript equivalent of Rust's RandomNumberGenerator trait which extends RngCore + CryptoRng.

    This is compatible with the RandomNumberGenerator Swift protocol used in MacOS and iOS, which is important for cross-platform testing.

    interface RandomNumberGenerator {
        nextU32(): number;
        nextU64(): bigint;
        fillBytes(dest: Uint8Array): void;
        randomData(size: number): Uint8Array;
        fillRandomData(data: Uint8Array): void;
    }

    Implemented by

    Index

    Methods

    • Fills the given Uint8Array with random bytes.

      Parameters

      • dest: Uint8Array

      Returns void

    • Returns a Uint8Array of random bytes of the given size.

      Parameters

      • size: number

      Returns Uint8Array

    • Fills the given Uint8Array with random bytes. Alias for fillBytes for compatibility.

      Parameters

      • data: Uint8Array

      Returns void