tencent cloud

Feedback

Encryption

Last updated: 2024-03-04 23:08:06

    getRandomValues

    This API is used via wx.getRandomValues(Object object).
    Feature Description: Gets cryptographically secure random numbers, with the usage method as follows.
    Parameter and Description: Object.
    Attribute
    Type
    Default value
    Required
    Description
    length
    number
    -
    Yes
    Integer, the byte size of the generated random number, with a maximum of 1048576.
    success
    function
    -
    No
    Callback Function of Successful Interface Call
    fail
    function
    -
    No
    Callback Function of Failing Interface Call
    complete
    function
    -
    No
    Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations)
    Parameters for object.success callback function: Object res.
    Attribute
    Type
    Description
    randomValues
    ArrayBuffer
    Random number content, with a length equivalent to the passed-in byte size.
    Sample Code
    wx.getRandomValues({
    length: 6 // Generate a random number of 6-byte length,
    success: res => {
    console.log(wx.arrayBufferToBase64(res.randomValues)) // Print after converting to a base64 string
    }
    })
    
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support