tencent cloud

Performance Testing Service

Overview
Purchase Guide
Billing Overview
Pay-as-You-Go (postpaid)
Purchasing Channels
Payment Overdue
Refund Instructions
Quick Start
Operation Guide
Performance Testing in Simple Mode
Performance Testing in Script Mode
Performance Testing in JMeter Mode
Project Management
Scenario Management
Traffic Recording
Environment Management
Scheduled Performance Testing
Performance Testing Report
Access Control
Alarm Management
Tag Management
Error Code Manual
Practice Tutorial
Using Prometheus To Monitor Performance Testing Metrics
Using PTS to Playback Requests Recorded by GoReplay
API Documentation
History
Introduction
API Category
Making API Requests
PTS-related APIs
Data Types
Error Codes
JavaScript API List
Overview of JavaScript API List
pts/global
pts/http
pts
pts/dataset
pts/grpc
pts/jsonpath
pts/protobuf
pts/redis
pts/sql
pts/url
pts/util
pts/ws
pts/socketio
pts/socket
FAQs
Related Agreements
Service Level Agreement
Use Limits
Privacy Policy
Data Processing And Security Agreement

util.base64Encoding

PDF
Focus Mode
Font Size
Last updated: 2025-03-10 17:23:46
During the script execution, util.base64Encoding is used for base64 encoding.
base64Encoding(input: string | ArrayBuffer, encoding?: "std" | "rawstd" | "url" | "rawurl"): string

Background

The different base64 encoding methods are as follows:
StdEncoding is the standard Base64 encoding as defined in RFC 4648.
RawStdEncoding is the standard raw, unpadded base64 encoding as defined in Section 3.2 of RFC 4648; it is the same as StdEncoding but omits the padding characters.
URLEncoding is the alternate base64 encoding defined in RFC 4648, typically used for URLs and file names.
RawURLEncoding is the unpadded alternate base64 encoding defined in RFC 4648, typically used for URLs and file names; it is the same as URLEncoding but omits the padding characters.

Parameters

Parameter
Type
Description
input
string or ArrayBuffer.
The string or byte array to be encoded.
encoding (optional)
"std", "rawstd", "url", or "rawurl".
Optional; represents the different encoding methods mentioned above. Defaults to "std" if left blank.

Return

Type
Description
string
The result obtained through Base64 encoding.

Usage Examples

Use the base64Encoding method without specifying encoding:
import util from 'pts/util';

export default function () {
// SGVsbG8sIHdvcmxk
console.log(util.base64Encoding('Hello, world'));
}
Use the base64Encoding method with a specified encoding:
import util from 'pts/util';

export default function () {
// aHR0cDovL3d3dy5leGFtcGxlLmNvbQ==
console.log(util.base64Encoding('http://www.example.com', 'url'));
}


Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback