(65)CRC32校验C语言版本
2024-10-07 04:38:36
- #include<iostream>
- # include <stdio.h>
- # include <string.h>
- typedef unsigned int uint ;
- uint POLYNOMIAL = 0xEDB88320 ;
- int have_table = 0 ;
- uint table[256] ;
- void make_table()
- {
- int i, j, crc ;
- have_table = 1 ;
- for (i = 0 ; i < 256 ; i++)
- for (j = 0, table[i] = i ; j < 8 ; j++)
- table[i] = (table[i]>>1)^((table[i]&1)?POLYNOMIAL:0) ;
- }
- uint crc32(uint crc, char *buff, int len)
- {
- if (!have_table) make_table() ;
- crc = ~crc;
- for (int i = 0; i < len; i++)
- crc = (crc >> 8) ^ table[(crc ^ buff[i]) & 0xff];
- return ~crc;
- }
- int main ()
- {
- char s[] = "676547657567";
- printf("%08Xh\n", crc32(0, s, strlen(s)));
- system("pause");
- return 0 ;
- }
最新文章
- 洛谷P1328 生活大爆炸版石头剪刀布——S.B.S.
- curl上传图片文件
- OpenSUSE 开启SSH 和网络设置
- 【zz】matlab 直方图匹配
- [转]const 与 readonly知多少
- Spring 注释 @Autowired 和@Resource
- WiFi基本知识
- protected(C# 参考)
- list、set、map的特点
- 手动启动angular
- C#显示声名接口就是为了解决方法重名的问题
- wamp mysql 创建主从数据库
- Tuxedo入门学�
- 【SoDiaoEditor更新啦】--谨以献给那些还在医疗行业奋斗的小伙伴们
- Python查找指定文件
- Loadrunner回放https脚本时出现错误Error -27780 Connection reset by peer解决办法
- 内网主机使用yum安装软件
- vs2017 编译vue 错误	TS2307	Build:找不到模块“webpack”。
- [leetcode]19. Remove Nth Node From End of List删除链表倒数第N个节点
- TCP template 代码