sha3
sha3
Helper function that will sha3 any value using keccak256.
Internally it will use Buffer.from(input, 'utf8')
to process the input first. If you want to hash a hexString or ByteArray, use TronWeb.utils.ethersUtils.keccak256(input)
.
Usage
TronWeb.sha3(value);
Parameters
Parameter | Description | Data Type |
---|---|---|
string | The string that needs to be hashed using Keccak-256 SHA3 algorithm. | String |
prefix | the result includes 0x prefix if set as true | Boolean |
Returns
String - The result hashed using the Keccak-256 SHA3 algorithm.
Example
> var hash = TronWeb.sha3("some string to be hashed");
console.log(hash)
> '0xc4b9bbe7eb8797cf2818085dbcd6ea6662b3261c28810c318e079c8d0c691da6'
> var hashOfHash = TronWeb.sha3(hash, false)
> '0xc4b9bbe7eb8797cf2818085dbcd6ea6662b3261c28810c318e079c8d0c691da6'