Skip to main content

randomBytes

Callable

  • randomBytes(size: number): Uint8Array

  • Returns a random byte array by the given bytes size

    @example
    console.log(web3.utils.randomBytes(32));
    > Uint8Array(32) [
    93, 172, 226, 32, 33, 176, 156, 156,
    182, 30, 240, 2, 69, 96, 174, 197,
    33, 136, 194, 241, 197, 156, 110, 111,
    66, 87, 17, 88, 67, 48, 245, 183
    ]

    Parameters

    • size: number

      The size of the random byte array returned

    Returns Uint8Array

    • random byte array