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

哈希函数

ripemd160

ripemd160 计算一个值的 Ripemd160 哈希。

输入

名称类型描述
valuebuffer | array[buffer]待哈希的十六进制编码值

输出

名称类型描述
valuestring哈希结果
output "hashed_data" {
value = ripemd160(encode_hex("hello, world"))
}
// > hashed_data: 0XA3201F82FCA034E46D10CD7B27E174976E241DA2

sha256

sha256 计算一个值的 sha256 哈希。

输入

名称类型描述
valuebuffer | array[buffer]待哈希的十六进制编码值

输出

名称类型描述
valuestring哈希结果
output "hashed_data" {
value = sha256(encode_hex("hello, world"))
}
// > hashed_data: 0x09ca7e4eaa6e8ae9c7d261167129184883644d07dfba7cbfbc4c8a2e08360d5b

keccak256

std::keccak256 计算一个值的 keccak256 哈希。

输入

名称类型描述
valuestring待哈希的字符串值

输出

名称类型描述
valuestring哈希结果
output "hashed_data" {
value = keccak256("hello, world")
}
// > hashed_data: 0x09ca7e4eaa6e8ae9c7d261167129184883644d07dfba7cbfbc4c8a2e08360d5b

Is this page helpful?

Table of Contents

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