Skip to content

Instantly share code, notes, and snippets.

@MCarlomagno
Created January 8, 2022 15:32
Show Gist options
  • Save MCarlomagno/eee3d906d13b105482f9d0af38a3dd30 to your computer and use it in GitHub Desktop.
Save MCarlomagno/eee3d906d13b105482f9d0af38a3dd30 to your computer and use it in GitHub Desktop.
checksum256 get_hash(const string &task, const account_name &contract)
{
checksum256 result;
size_t tasklen = strlen(task.c_str());
char *buffer = (char *)malloc(tasklen + 8);
memcpy(buffer, &contract, 8);
memcpy(buffer + 8, task.data(), tasklen);
sha256(buffer, tasklen + 8, &result);
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment