sha3

使用keccak-256哈希算法,计算给定字符串的哈希值。

用法

tronWeb.sha3(string, prefix=true)

参数
1.string - String: 传入的需要使用Keccak-256 SHA3算法进行哈希运算的字符串。
2.prefix - Boolean: 可选项,返回结果中是否包括前缀0x,true表示带前缀0x,false表示不带前缀0x,如果不填,则为默认值true。

返回
String - 使用Keccak-256 SHA3算法哈希的结果。

示例

var hash = tronWeb.sha3("some string to be hashed");
console.log(hash)
>0xc4b9bbe7eb8797cf2818085dbcd6ea6662b3261c28810c318e079c8d0c691da6
var hashOfHash = tronWeb.sha3(hash,true)
console.log(hashOfHash)
>0xfbb2fed40430ff0be9383df03e5a92a8a59eaec7a1a54cf6e1e681d69106e969
var hash1 = tronWeb.sha3("some string to be hashed",false);
console.log(hash1)
>c4b9bbe7eb8797cf2818085dbcd6ea6662b3261c28810c318e079c8d0c691da6