tencent cloud

All product documents
Tencent Cloud Observability Platform
Third-Party Package Reference
Last updated: 2025-03-10 22:14:20
Third-Party Package Reference
Last updated: 2025-03-10 22:14:20
Script-based performance testing of PTS supports native JavaScript ES5.1 syntax and most ES6 syntax. For PTS, it is recommended to use the PTS native JavaScript library to implement your features.
Third-party package reference is an experimental feature. If the native library does not meet your needs, you can try loading remote HTTP(S) modules as third-party packages for reference. However, PTS does not guarantee that the syntax of the third-party packages you reference can be correctly parsed.
When the performance testing engine starts, it will download third-party scripts and their dependency information, and execute user scripts.
Note:
The referenced packages should be lightweight enough to ensure the smooth execution of the performance testing scripts.
PTS is not NodeJS. Therefore, loading NodeJS libraries in third-party scripts will not take effect.
TypeScript syntax is not supported.
Functions in the browser, such as setTimeout and XMLRequest, are not supported.

Common Websites for Searching for Remote Modules

Click the module website.

Common Remote Modules

crypto

For details, see crypto-js.
import crypto from 'https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.1.1/crypto-js.js'

export default function () {
console.log(crypto.MD5('Message')); // 4c2a8fe7eaf24721cc7a9f0175115bd4
console.log(crypto.SHA1('Message')); // 68f4145fee7dde76afceb910165924ad14cf0d00
console.log(crypto.SHA256('Message')); // 2f77668a9dfbf8d5848b9eeb4a7145ca94c6ed9236e4a773f6dcafa5132b2f91
console.log(crypto.SHA512('Message')); // 4fb472dfc43def7a46ad442c58ac532f89e0c8a96f23b672f5fd637652eab158d4d589444ef7530a34e6626b40830b4e1ec5364611ae31c599bffa958e8b4c4e
console.log(crypto.SHA384('Message')); // b526d8394134b853bd071719bc99d42b669bc9252baa82dcafabc1f322a3841c57cc0c82f080fd331b1666112b27a329
console.log(crypto.RIPEMD160('Message')); // 85eab2fe4383a869da13d51f4b91506924b1f821

console.log(crypto.HmacMD5('Message', 'Secret Passphrase')); // 5e03d0c1b42ef0b7e61fb333f3993949
console.log(crypto.HmacSHA1('Message', 'Secret Passphrase')); // e90f713295ea4cc06c92c9248696ffafc5d01faf
console.log(crypto.HmacSHA256('Message', 'Secret Passphrase')); // 32c647602ab4c4c7543e9c50ae25e567c3354e1532b11649ce308e6e2568d205
console.log(crypto.HmacSHA512('Message', 'Secret Passphrase')); // c03f82cd6f9d03920d95caeedfa722d4e42325a18b049942ee5560787ad2aa394be6b95849c563ecdd37495726cd6236529a721b563b9778dd6119939bcab7e1
console.log(crypto.HmacSHA384('Message', 'Secret Passphrase')); // 84b318cc0232a370c1f8b8746afcb575fc2debc680122c7422fd425638896d0dcf9e905b8cd9c1d7aed8d5439a2a2328
console.log(crypto.HmacRIPEMD160('Message', 'Secret Passphrase')); // d1b4088aba7f4897444c1423c0b1f056605473ab

let words = crypto.enc.Base64.parse('SGVsbG8sIFdvcmxkIQ==');
console.log(words); // 48656c6c6f2c20576f726c6421

let base64 = crypto.enc.Base64.stringify(words);
console.log(base64); // SGVsbG8sIFdvcmxkIQ==

words = crypto.enc.Latin1.parse('Hello, World!');
console.log(words); // 48656c6c6f2c20576f726c6421

let latin1 = crypto.enc.Latin1.stringify(words);
console.log(latin1); // Hello, World!

words = crypto.enc.Hex.parse('48656c6c6f2c20576f726c6421');
console.log(words); // 48656c6c6f2c20576f726c6421

let hex = crypto.enc.Hex.stringify(words);
console.log(hex); // 48656c6c6f2c20576f726c6421

words = crypto.enc.Utf8.parse('?');
console.log(words); // f094ada2

let utf8 = crypto.enc.Utf8.stringify(words);
console.log(utf8); // ?

words = crypto.enc.Utf16.parse('Hello, World!');
console.log(words); // 00480065006c006c006f002c00200057006f0072006c00640021

let utf16 = crypto.enc.Utf16.stringify(words);
console.log(utf16); // Hello, World!

words = crypto.enc.Utf16LE.parse('Hello, World!');
console.log(words); // 480065006c006c006f002c00200057006f0072006c0064002100

utf16 = crypto.enc.Utf16LE.stringify(words);
console.log(utf16); // Hello, World!
}

aes

For details, see relevant documents.
import aesjs from 'https://cdnjs.cloudflare.com/ajax/libs/aes-js/4.0.0-beta.2/index.js'

export default function () {
// An example 128-bit key (16 bytes * 8 bits/byte = 128 bits)
var key = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16];

// Convert text to bytes
var text = 'Text may be any length you wish, no padding is required.';
var textBytes = aesjs.utils.utf8.toBytes(text);

// The counter is optional, and if omitted will begin at 1
var aesCtr = new aesjs.ModeOfOperation.ctr(key, new aesjs.Counter(5));
var encryptedBytes = aesCtr.encrypt(textBytes);

// To print or store the binary data, you may convert it to hex
var encryptedHex = aesjs.utils.hex.fromBytes(encryptedBytes);
console.log(encryptedHex);
// "a338eda3874ed884b6199150d36f49988c90f5c47fe7792b0cf8c7f77eeffd87
// ea145b73e82aefcf2076f881c88879e4e25b1d7b24ba2788"

// When ready to decrypt the hex string, convert it back to bytes
var encryptedBytes = aesjs.utils.hex.toBytes(encryptedHex);

// The counter mode of operation maintains internal state, so to
// decrypt a new instance must be instantiated.
var aesCtr = new aesjs.ModeOfOperation.ctr(key, new aesjs.Counter(5));
var decryptedBytes = aesCtr.decrypt(encryptedBytes);

// Convert our bytes back into text
var decryptedText = aesjs.utils.utf8.fromBytes(decryptedBytes);
console.log(decryptedText);
// "Text may be any length you wish, no padding is required."
}

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

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