示例#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);
}