代码语言
.
CSharp
.
JS
Java
Asp.Net
C
MSSQL
PHP
Css
PLSQL
Python
Shell
EBS
ASP
Perl
ObjC
VB.Net
VBS
MYSQL
GO
Delphi
AS
DB2
Domino
Rails
ActionScript
Scala
代码分类
文件
系统
字符串
数据库
网络相关
图形/GUI
多媒体
算法
游戏
Jquery
Extjs
Android
HTML5
菜单
网页交互
WinForm
控件
企业应用
安全与加密
脚本/批处理
开放平台
其它
【
CSharp
】
CRC8校验
作者:
Dezai.CN
/ 发布于
2012/7/9
/
463
CRC8校验
<div>1. 查表法:</div> <div></div> <div>public class CRC8 { /// <summary> /// CRC8位校验表 /// </summary> private byte[] CRC8Table = new byte[] { ,94,188,226,97,63,221,131,194,156,126,32,163,253,31,65, ,195,33,127,252,162,64,30, 95,1,227,189,62,96,130,220, ,125,159,193,66,28,254,160,225,191,93,3,128,222,60,98, ,224,2,92,223,129,99,61,124,34,192,158,29,67,161,255, ,24,250,164,39,121,155,197,132,218,56,102,229,187,89,7, ,133,103,57,186,228,6,88,25,71,165,251,120,38,196,154, ,59,217,135,4,90,184,230,167,249,27,69,198,152,122,36, ,166,68,26,153,199,37,123,58,100,134,216,91,5,231,185, ,210,48,110,237,179,81,15,78,16,242,172,47,113,147,205, ,79,173,243,112,46,204,146,211,141,111,49,178,236,14,80, ,241,19,77,206,144,114,44,109,51,209,143,12,82,176,238, ,108,142,208,83,13,239,177,240,174,76,18,145,207,45,115, ,148,118,40,171,245,23,73,8,86,180,234,105,55,213,139, ,9,235,181,54,104,138,212,149,203, 41,119,244,170,72,22, ,183,85,11,136,214,52,106,43,117,151,201,74,20,246,168, ,42,200,150,21,75,169,247,182,232,10,84,215,137,107,53 };</div> <div> public byte CRC(byte[] buffer) { return CRC(buffer, 0, buffer.Length); } <div> public byte CRC(byte[] buffer, int off, int len) { byte crc = 0; if (buffer == null) { throw new ArgumentNullException("buffer"); } if (off < 0 || len < 0 || off + len > buffer.Length) { throw new ArgumentOutOfRangeException(); } <div> for (int i = off; i < len; i++) { crc = CRC8Table[crc ^ buffer[i]]; } return crc; } } <div></div> <div>2. 计算法1:</div> <div></div> <div>public static byte CRC8(byte[] buffer) { byte crc = 0; for (int j = 0; j < buffer.Length; j++) { crc ^= buffer[j]; for (int i = 0; i < 8; i++) { if ((crc & 0x01) != 0) { crc >>= 1; crc ^= 0x8c; } else { crc >>= 1; } } } return crc; } <div></div> <div>3. 计算法2:</div> <div></div> <div>public byte CRC8(byte[] buffer) { byte crc=0; for (int j=0;j<buffer.Length;j++) { for (int i = 1; i != 0; i *= 2) { if ((crc & 1) != 0) { crc /= 2; crc ^= 0x8C; } else { crc /= 2; } if ((buffer[j] & i) != 0) crc ^= 0x8C; } } return crc; }
试试其它关键字
CRC8校验
同语言下
.
文件IO 操作类库
.
Check图片类型[JPEG(.jpg 、.jpeg),TIF,GIF,BMP,PNG,P
.
机器名和IP取得(IPV4 IPV6)
.
Tiff转换Bitmap
.
linqHelper
.
MadieHelper.cs
.
RegHelper.cs
.
如果关闭一个窗体后激活另一个窗体的事件或方法
.
创建日志通用类
.
串口辅助开发类
可能有用的
.
C#实现的html内容截取
.
List 切割成几份 工具类
.
SQL查询 多列合并成一行用逗号隔开
.
一行一行读取txt的内容
.
C#动态修改文件夹名称(FSO实现,不移动文件)
.
c# 移动文件或文件夹
.
c#图片添加水印
.
Java PDF转换成图片并输出给前台展示
.
网站后台修改图片尺寸代码
.
处理大图片在缩略图时的展示
Dezai.CN
贡献的其它代码
(
4037
)
.
多线程Socket服务器模块
.
生成随机密码
.
清除浮动样式
.
弹出窗口居中
.
抓取url的函数
.
使用base HTTP验证
.
div模拟iframe嵌入效果
.
通过header转向的方法
.
Session操作类
.
执行sqlite输入插入操作后获得自动编号的ID
Copyright © 2004 - 2024 dezai.cn. All Rights Reserved
站长博客
粤ICP备13059550号-3