Qt World Summit: Submit your Presentation

Qt checksum

  • I'am trying to use the cecksum of QT - "qchecksum":http://doc.qt.nokia.com/4.7-snapshot/qbytearray.html#qChecksum
    According to the document, this function use CRC-16-CCITT algorithm.
    but when I use this function, I don't get the correct crc.

    for example:
    char str[]= "123456789";
    quint16 qchecksum = qChecksum(str,9);

    qchecksum = 0x906E.

    but the correct checksum shold be 0x31C3 according to some calculator of checksum and other documents.
    does anyone know how to use this function?

    [EDIT: fixed link, Volker]

  • If you look at "Appendix A":http://regregex.bbcmicro.net/crc-catalogue.htm#appendix.a of http://regregex.bbcmicro.net/crc-catalogue.htm you can see a map of checksums using various parameters for the CRC algorithms.

    0x31C3 is the result of using an initial value of 0x0000, a final XOR with 0x0000, a polynom of 0x1021 and not using reflection - aka XMODEM

    0x906E, the Qt result, is for using an initial value of 0xFFFF, a final XOR with 0xFFFF, polynom 0x1021 and using reflection - aka X.25

    So, it's extremely important to use the very same parameters to calculate the checksum.

Log in to reply