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
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
Comment