Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include "cryptonote_basic/cryptonote_format_utils.h"
- using namespace cryptonote;
- using namespace std;
- std::string string_to_hex(const std::string& input)
- {
- static const char hex_digits[] = "0123456789abcdef";
- std::string output;
- output.reserve(input.length() * 2);
- for (unsigned char c : input)
- {
- output.push_back(hex_digits[c >> 4]);
- output.push_back(hex_digits[c & 15]);
- }
- return output;
- }
- // convert hex string to string that has values based on that hex
- // thankfully should automatically ignore null-terminator.
- std::string h2b(const std::string &s) {
- bool upper = true;
- std::string result;
- unsigned char val = 0;
- for (char c : s) {
- if (upper) {
- val = 0;
- if (c <= 'f' && c >= 'a') {
- val = ((c - 'a') + 10) << 4;
- } else {
- val = (c - '0') << 4;
- }
- } else {
- if (c <= 'f' && c >= 'a') {
- val |= (c - 'a') + 10;
- } else {
- val |= c - '0';
- }
- result += (char) val;
- }
- upper = !upper;
- }
- return result;
- }
- int main() {
- blobdata b_blob = h2b(
- "0c0ce185b0f2053941deed208d6449bb432fbce9778efb4cd9229cc79e4c04ef7b2a2f7c99df4a0000000002afdd1f01fff3dc1f018f918980888803025b08e22c6cb11c61b628de4217c3959627414d2d10579b780ca1e1fec0164bba210174b9819eb50c698d574bc408a0f7fedd608296647291551e98be4f7134bc26660000");
- blobdata hashing_blob;
- cout << "Input:\t" << string_to_hex(b_blob) << endl;
- block b = AUTO_VAL_INIT(b);
- if (!parse_and_validate_block_from_blob(b_blob, b)) {
- cout << "Not valid blob" << endl;
- return -1;
- }
- hashing_blob = get_block_hashing_blob(b);
- cout << "Output:\t" << string_to_hex(hashing_blob) << endl;
- return 0;
- }
Advertisement
Advertisement
Advertisement
RAW Paste Data
Copied
Advertisement