tencent cloud

All product documents
Tencent Cloud Super App as a Service
Encryption
Last updated: 2024-11-21 18:48:11
Encryption
Last updated: 2024-11-21 18:48:11

getRandomValues

This API is used via wx.getRandomValues(Object object).
Feature Description: Gets cryptographically secure random numbers.
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
}
})

Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback

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 available.

7x24 Phone Support
Hong Kong, China
+852 800 906 020 (Toll Free)
United States
+1 844 606 0804 (Toll Free)
United Kingdom
+44 808 196 4551 (Toll Free)
Canada
+1 888 605 7930 (Toll Free)
Australia
+61 1300 986 386 (Toll Free)
EdgeOne hotline
+852 300 80699
More local hotlines coming soon