online casino

Implement XOR Checksum in Qt.


I got the code from this php forum (phpfreaks,digitalpoint). I just re-implemented in Qt. Thank you rajoo.sharma for sharing with us.

void MainWindow::xorchecksum(QString HEXStr)
{
    QByteArray HEXData = QByteArray::fromHex(HEXStr.toAscii());
    qDebug() << "";
    qDebug() << "HEX String: " << HEXData.toHex().toUpper() << " Byte Count: " << HEXData.length();

    unsigned char charA = NULL;
    unsigned char charB = NULL;
    unsigned char charC = NULL;

    charA = HEXData[0];
    for (int i = 1; i < HEXData.length()-1; i++)
    {
        charC = charA ^ HEXData[i+1];
        charA = charC;
    }

    qDebug() << "CheckSum: " << charC;
}

call it as:
xorchecksum(“A00000042000AF”);
Result: DEC: 43 HEX: 2B
xorchecksum(“0191050902040843d1″);
Result: DEC: 145 HEX: 91

, , , ,

  1. #1 by freenode asshole on June 10, 2012 - 1:34 am

    Hi,

    I’m an asshole from Freenode, and I found your website from your /quit message. Please go choke on a bucket of cocks and die in a fire. Your code is gay and you’re probably a sperger. In particular, why the fuck would anyone using C++ turn a hexadecimal number into a string to pass it to an utterly trivial hash function. This is how bloatware happens. If you want to be using a scripting language, use a damn scripting language.

    Cheers,
    ~Freenode Asshole

    • #2 by admin on June 13, 2012 - 10:25 pm

      Thank you for your comment Freenode asshole. =)

(will not be published)


Refresh