谁做过 crc8查表法校验啊 ~~~~

wlpsgh 2008-11-03 04:38:14
表已经构造好了,但是由于原理理解不够充分,具体算法还不太会,希望大虾们帮解决完成!

public byte[] crc_table = new byte[256];

#region 构造对应表
/// <summary>
/// 构造对应表(h(x) = x^8+ x^5+ x^4 + 1)
/// </summary>
public CRC8()
{
crc_table[0] = 0;
crc_table[1] = 94;
crc_table[2] = 188;
crc_table[3] = 226;
crc_table[4] = 97;



crc_table[254] = 107;
crc_table[255] = 53;
}
#endregion


#region IVerifier 成员
/// <summary>
/// 生成crc8
/// </summary>
/// <param name="_valueString">被校验字符</param>
/// <returns>返回校验码</returns>
public string GenerateVerifyHexString(string _valueString)
{

int i;
int index;
int crc_High = 0x00;
//将十六进制数直接保存到数组中
byte[] mod = new byte[_valueString.Length];
for (int m = 0; m < _valueString.Length; m++)
{
mod[m] = Convert.ToByte(_valueString[m].ToString(), 16);
}
//核心算法
for (i = 0; i < _valueString.Length; i++)
{
此处应该怎么写????
}
int temp = crc_High;
string Verify = temp.ToString("X");
return Verify; }
...全文
631 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
supawei 2008-11-04
  • 打赏
  • 举报
回复
看看这个:
http://topic.csdn.net/t/20050620/11/4093638.html

如果你不是用在嵌入式系统上,推荐按字节计算。那点内存对pc来讲小意思。
pvgyetg 2008-11-03
  • 打赏
  • 举报
回复
友情UP

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧