Search code examples
blockchainsmartcontractswavesplatformride

sha256 returns strange 44 symbols hash (not 64 as usual)


I'm trying to use built-in function "sha256" in my Waves dApp. https://docs.wavesplatform.com/en/ride/built-in-functions.html

'DataEntry("sha256_kotobytesto64", toBase64String(sha256(toBytes("Message to hash"))))'

But it seems like the result of this function is not the same as major open source sha256 implementations (https://www.xorbin.com/tools/sha256-hash-calculator):

Text: Message to hash

RIDE: 8apFsPX2cDRo+bm8K5h01PprABoXDQ8TKqWibQDQx+U=

Standart: f1aa45b0f5f6703468f9b9bc2b9874d4fa6b001a170d0f132aa5a26d00d0c7e5

How to solve it?


Solution

  • base-16 will be supported in near future

    I used a bit different approach with waves-crypto lib

    base58encode(sha256(stringToUint8Array("string"))) from client-side

    DataEntry("key_string", toBase58String(sha256(toBytes("string"))))

    It'll help with any commit-reveal based smart contracts in RIDE for dApps