Function getSecureRandom

  • generate a secure random hexadecimal string

    Parameters

    • nbyte: number

      length of random bytes

    Returns string

    hexadecimal string of generated random bytes

    Description

    This function generates a secure random hexadecimal string with specified bytes by crypto.getRandomValues() which uses a pseudo-random number generator(PRNG) algorithm.

    Example

    getSecureRandom(3) -> "f73ad5"
    getSecureRandom(3) -> "d431c6"
    getSecureRandom(256) -> "147ac8..." (string length will be 512=256*2)