Announcement

Collapse
No announcement yet.

CRC-Fehler

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • CRC-Fehler

    Hallo Leutz,
    ich generiere von einem Bild eine CRC-Checksum, um zu überprüfen, ob es schon einzelne Bilder gibt.
    Der gibt mir aber für jedes Bild den gleichen crc-Wert.
    Warum?
    <br>
    static const unsigned int crc_tab[16] =
    {
    0x0000, 0x1081, 0x2102, 0x3183,
    0x4204, 0x5285, 0x6306, 0x7387,
    0x8408, 0x9489, 0xA50A, 0xB58B,
    0xC60C, 0xD68D, 0xE70E, 0xF78F
    };
    <br>
    vector<unsigned char> daten;
    unsigned int s;
    int ss;
    unsigned short crc_wert = 0xffff;

    ifstream dat;
    dat.open(path.c_str(), ios::binary | ios::in);

    dat.seekg(ios::end);
    ss = dat.tellg();
    daten.resize(ss);
    dat.seekg(ios::beg);

    if(!dat)
    ShowMessage("Failed to open File");
    else
    {
    dat.read(&daten.at(0), ss);

    dat.close();

    for (s = 0; s < daten.size(); s++)
    crc_wert = crc_update (crc_wert, daten.at(s));
    }
    return crc_wert;
    <br>
    unsigned short crc_update (unsigned short crc, unsigned char c)
    {
    crc = (((crc >> 4) & 0x0FFF) ^ crc_tab[((crc ^ c) & 0x000F)]);
    crc = (((crc >> 4) & 0x0FFF) ^ crc_tab[((crc ^ (c>>4)) & 0x000F)]);
    return crc;
    }<br>
    MfG
    Muecke

  • #2
    http://www.c-plusplus.de/forum/viewtopic-var-t-is-105629-and-postdays-is-0-and-postorder-is-asc-and-start-is-0.htm

    Comment


    • #3
      die CRC ist eine CheckSUMME.

      crc_wert wird bei jedem bearbeiteten Byte NEU BESCHRIEBEN,
      das letzte Byte ist vermutlich ein eof - Zeichen

      Comment

      Working...
      X