ahhhh era eso
ahora lo cambie para mejor, aver asi
ahora lo cambie para mejor, aver asi
Código [Seleccionar]
#include <fstream>
#include <iostream>
using namespace std;
const int BUFFERSIZE1 = 1024;
class CRC32
{
private:
int crc32Table[];
//const int BUFFERSIZE1 = 1024;
static char result[400];
public:
int GetCrc32(ifstream& stream)
{
int crc32Result = 0xFFFFFFFF;
BYTE buffer[BUFFERSIZE1];
int readSize = BUFFERSIZE1;
//stream.read( (char*)buffer, readSize);
int count = stream.get();
int i;
int iLookup;
while (count > 0)
{
for(i = 0; i<= count - 1;i++)
{
iLookup = (crc32Result & 0xFF) ^ buffer[i];
crc32Result = ((crc32Result & 0xFFFFFF00) / 0x100) & 0xFFFFFF;// nasty shr 8 with vb :/
crc32Result = crc32Result ^ crc32Table[iLookup];
}
//stream.read(buffer, readSize);
count = stream.get();
}
return !(crc32Result);
}
const char* GetCrc32String(ifstream& stream)
{
//Return String.Format("{0:X8}", GetCrc32(stream))
result[0]=0;
sprintf(result, "0x%X",GetCrc32(stream));
return result;
}
void New()
{
//' This is the official polynomial used by CRC32 in PKZip.
//' Often the polynomial is shown reversed (04C11DB7).
int dwPolynomial = 0xEDB88320;
int i, j;
int crc32Table[256];
int dwCrc;
for(i = 0; i<256;i++)
{
dwCrc = i;
for(j = 8; j>-1; j--)
{
if((dwCrc & 1) > 0)
{
dwCrc = ((dwCrc & 0xFFFFFFFE) / 2) & 0x7FFFFFFF;
dwCrc = dwCrc ^ dwPolynomial;
}
else
{
dwCrc = ((dwCrc & 0xFFFFFFFE) / 2) & 0x7FFFFFFF;
}
}
crc32Table[i] = dwCrc;
}
}
};