Skip to content

I cracked the chain #3

Description

@kenhero

I cracked the chain and it says it's still valid

// Someone's getting sneaky
Block *hackBlock = awesomeCoin.getLatestBlock();
cout << "Hash = " << hackBlock->getHash() << endl << "Previous Hash is " << hackBlock->getPreviousHash() << endl << "Is valid Hash? " << hackBlock->isHashValid() << endl;
//creo transactiondata fake con modificato solo ammontare e destinatario e stesso timestamp
TransactionData d(10000, hackBlock->data.senderKey, "Jon", hackBlock->data.timestamp);
Block b(hackBlock->getIndex(), d, hackBlock->getPreviousHash());

//stampa dell ultimo block della chain prima di provare a crakkare,dovrebbe essere tutto ok
//cout << "Hash = " << hackBlock->getHash() << endl << "Previous Hash is " << hackBlock->getPreviousHash() << endl << "Is valid Hash? " << hackBlock->isHashValid() << endl;
*hackBlock = b;
//test dopo modifica
//cout << "Hash = " << hackBlock->getHash() << endl << "Previous Hash is " << hackBlock->getPreviousHash() << endl << "Is valid Hash? " << hackBlock->isHashValid() << endl;


/*hackBlock->data.amount = 10000; // Oh yeah!
hackBlock->data.receiverKey = "Jon"; // mwahahahaha!
//cout << "Hash = " << hackBlock->getHash() << endl << "Previous Hash is " << hackBlock->getPreviousHash() << endl << "Is valid Hash? " << hackBlock->isHashValid() << endl;
*/
// Let's look at data
awesomeCoin.printChain();

// Awww! Why is it not valid?
printf("\nIs chain still valid? %d\n", awesomeCoin.isChainValid());

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions