📄 crc.cpp
字号:
// Created:09-25-98
// By Jeff Connelly
// Compute CRCs. A CRC is a value based on some data to test its integerty.
// For example, when a file is transfured over the Internet, a CRC value
// is appended to it based on the file contents. When the file is recivied
// on another computer, it performs the same CRC calculation. If the CRC
// just calculated does not match the appended CRC, the file is downloaded
// again.
#include "stdafx.h"
#define EXPORTING
#include "comprlib.h"
#include "crc.h"
// Updates 'crc' using character 'c'. To calculate the CRC of a file,
// read and update each character using this function:
// while (!feof(file))
// {
// c = getc(file);
// UpdateCRC (crc, c);
// }
unsigned int EXPORT UpdateCRC (unsigned int crc, int c)
{
int i;
printf ("Character: %c\n", c);
i = (crc >> 8) ^ c;
printf ("'i' var: %d\n", i);
crc = (crc << 8) ^ crctttab[i];
printf ("CRC now is: %d\n", crc);
return crc;
}
// Reverse of UpdateCRC(). See UpdateCRC() notes for explaination.
unsigned int EXPORT UpdateCRCReverse (unsigned int crc, int c)
{
int i;
i = crc ^ c;
crc = (crc >> 8) ^ crc16tab[i & 0xFF];
return crc;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -