Different value of sha256 on-chain than off-chain

72 Views Asked by At

I am using HFB 1.4.6, and I emit chaincode logs, which I capture one by one, to apply sha256 and base64 to each. However the sha256 result varies with respect to the sha256 off-chain verification.

This is the chaincode output: enter image description here

This is the online verification: enter image description here

I have reproduce the same scenario of functions used in play.golang instance: https://play.golang.org/p/2iVVKMMa7fA

1

There are 1 best solutions below

0
On BEST ANSWER

I have solved the issue since I was omitting the '\n' character at the end of the log. So I have added the next line to remove the endline character:

logStringWoutN := strings.TrimSuffix(logString, "\n")