示例#1
0
void testCRC32()
{
    cout << CRC32String("abc") << endl;
    cout << CRC32File("C:\\boot.ini") << endl;
    cout << CRC32File("C:\\a\\a.a") << endl;

    CRC32 crc32;
    crc32.Init();
    crc32.Update("", 0);
    crc32.Update("a", 1);
    crc32.Update("bc", 2);
    crc32.Update("defghijklmnopqrstuvwxyz",
                 (unsigned int)strlen("defghijklmnopqrstuvwxyz"));
    crc32.Final();
    Print("abcdefghijklmnopqrstuvwxyz", crc32);

    crc32.Init();
    crc32.Update("", 0);
    crc32.Update("a", 1);
    crc32.Update("bc", 2);
    crc32.Update("defghijklmnopqrstuvwxyz",
                 (unsigned int)strlen("defghijklmnopqrstuvwxyz"));
    crc32.Final();
    Print("abcdefghijklmnopqrstuvwxyz", crc32);

    CRC32 obj;
    obj.Init();
    obj.Update("abcdefghijklmnopqrstuvwxyz",
               (unsigned int)strlen("abcdefghijklmnopqrstuvwxyz"));
    obj.Final();
    Print("abcdefghijklmnopqrstuvwxyz", obj);
}
示例#2
0
Uint32 MessageOut::addCRC(){
	CRC32 msgCRC;
	Uint32 crc;

	msgCRC.Init();
	crc = msgCRC.GetCRC(this->myData, (this->pos));

	write4(crc);

	return crc;
}