Solana 文档基础设施即代码标准库

Base64 函数

encode_base64

encode_base64 将缓冲区或字符串编码为 base64 字符串。

输入

名称类型描述
valuebuffer、string、addon要编码的缓冲区或字符串。以 '0x' 开头的字符串将被解码为十六进制;否则,使用原始 UTF-8 字节。

输出

名称类型描述
valuestring输入内容编码后的 base64 字符串
output "encoded" {
value = encode_base64("0x48656c6c6f20776f726c6421")
}
// > encoded: SGVsbG8gd29ybGQh

decode_base64

decode_base64 解码 base64 编码的字符串,并将结果以缓冲区形式返回。

输入

名称类型描述
base64_stringstring要解码的 base64 字符串

输出

名称类型描述
valuebuffer解码后的 base64 字符串,以缓冲区形式返回
output "decoded" {
value = decode_base64("SGVsbG8gd29ybGQh")
}
// > decoded: 0x48656c6c6f20776f726c6421

Is this page helpful?

Table of Contents

Edit Page
©️ 2026 Solana 基金会版权所有