0

fist off let me get this strait, yes I know the dangers of memo parsing, yes I am aware of the vulnerabilities that can be created from doing such a process, so please there is no need to lecture me about the things I am already aware of.

i'm doing some string parsing and need to convert a string value of a checksum256 to a checksum256 type;

so like

string hash_string = "a6f7b874ea69329372ad75353314d7bcacd8c0be365023dab195bcac015d6009";

to

checksum256 hash = <hash_string>;

I have found the other way around to make checksum256 into a string but not string to checksum256.

1
  • I see this can take up to a year to get an answer here. . . Aug 18, 2020 at 17:45

1 Answer 1

1
string hash_string = "a6f7b874ea69329372ad75353314d7bcacd8c0be365023dab195bcac015d6009";

char hash_char_array[32] = ConvertHexStringToCharArray(); // You have to convert the Hex string to a 32-byte long char-array, which seems to be the biggest problem.

auto hash = eosio::checksum256::make_from_word_sequence<char>(hash_char_array[0], hash_char_array[1], ..., ..., hash_char_array[31]);

take a look here, for a full example.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.