I should compare two hashes and the scenario is the following:
I create a new record in the contract as I pass eosjs-ecc sha256 generated hash as string. Let name it hashA.
When I want to update the record, I should pass the plain data to the contract and the contract should hash it. Let name the resulted hash - hashB.
Unfortunately when I am comparing the hashA to hashB, they are always different
The code example is here:
1) eosjs-ecc hashing ->
let a = eosECC.sha256(JSON.stringify("Hello));
eosECC.sha256(Buffer.from(a, 'hex'))
2) Contract hashing ->
ACTION mycontract::update(name account, const string data)
{
require_auth(account);
auto iteratorDataRecord = recordTable.find(0);
checksum256 sum = sha256(const_cast<char *>(data.c_str()), data.size());
print("EOS cpp hash", sum);
// iteratorDataRecord->hashed_data is string
print("eosjs-ecc hash", iteratorDataRecord->hashed_data);
}
I am calling the contract action in this way :
cleos push action mycontract update '{"account": "myself", "data":"Hello"}' -p myself@active
Do I have to convert from checksum to hex and if so how to do that ?