tronprotocol / tronweb

Javascript API Library for interacting with the TRON Network
MIT License
413 stars 271 forks source link

`TronWeb.sha3` result differs from `TronWeb.utils.ethersUtils.keccak256` when hashing hex string #450

Closed alienzhangyw closed 9 months ago

alienzhangyw commented 9 months ago

image You can try it in your browser.

But your Java Trident package's Hash.sha3 result is the same as TronWeb.utils.ethersUtils.keccak256.

Expected for the same hash result for both front-end and back-end.

svein1010 commented 9 months ago

tronWeb.sha3() is used to hash the utf8 string. It will use Buffer.from(message, 'utf8') to process the input. TronWeb.utils.ethersUtils.keccak256() only receive hexString or BytesArray.

alienzhangyw commented 9 months ago

tronWeb.sha3() is used to hash the utf8 string. It will use Buffer.from(message, 'utf8') to process the input. TronWeb.utils.ethersUtils.keccak256() only receive hexString or BytesArray.

image The document should be clearer like you said.