如题.
生成多项式为:X^16+X^12+X^5+1,高8位在前
生成多项式为:X^16+X^12+X^5+1,高8位在前
解决方案 »
- 求救,系统类型
- 自已怎么做不规则形状的按钮呀?
- [版主手下留情,俺不知到哪问] WinCVS使用错误请教:cvs [chacl aborted]: server does not support chacl
- 如何用delphi下载一个网页
- 請問一下下面這段代碼有什么區別﹐關于create(...)的
- 如何取得DBGrid中总的记录个数???
- 这个网页的内容如何读取呢?
- 報表設計
- 欢迎光临我的Delphi游戏源码原创网站----Thirdapple.home.chinaren.com,提一些意见!
- Delphi能不能写真正的DLL?不是ActiveX DLL
- Delphi 中的Boolean的返回值
- ACCESS入库问题,急在线等(DELPHI语言)
Form1: TForm1;
vCRC16Table: array[Byte] of Word; //CRC16表
implementation{$R *.dfm}
function UpdateCRC16( //更新CRC16的值
mChar: Char; //字符
mSeed: Word //Seed
): Word; //返回更新后的CRC16值
begin
result :=
vCRC16Table[(mSeed and $000000FF) xor Byte(mChar)] xor (mSeed shr 8);
end; { UpdateCRC16 }function StringCRC16( //取得字符串的CRC16值
mString: string //字符串
): Word; //返回字符串的CRC16值
var
I: Integer;
begin
result := $FFFF;
for I := 1 to Length(mString) do result := UpdateCRC16(mString[I], result);
result := not result;
end; { StringCRC16 }
上面网址里有源代码,包括lookup table的生成算法,
你应该仔细看看:
/////////////////////////////////////////////
For a CRC-16, the lookup table consists of 256 2-byte WORDs (see below, or the CRC16.PAS unit for the actual table, or the CRCTable program for computation of the lookup table for the x16 + x15 + x2 + 1 generator polynomial):
/////////////////////////////////////////////
PROGRAM CRCTable;
{CRCTable generates the table of constants needed for byte-wise CRC-16
calculations. The constants are formatted for inclusion in the
CRC UNIT. (C) Copyright 1989, Earl F. Glynn, Overland Park, KS. Compuserve 73257,3527.
All Rights Reserved. This Turbo Pascal 5.5 PROGRAM may be freely distributed
for non-commercial use. This program was derived from the CRCV FORTRAN 77 program given in
"Byte-wise CRC Calculations" by Aram Perez in IEEE Micro, June 1983,
pp. 40-50. The constants here are for the CRC-16 generator polynomial
X^16 + X^15 + X^2 + 1. Other generator polynomials could be used
but a new derivation would be needed to calculate the 'v' variables
below.}