-
(65)CRC32校验C语言版本
- #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
", crc32(0, s, strlen(s)));
- system("pause");
- return 0 ;
- }
-
相关阅读:
如何用JS判断身份证格式
ELK+log4j笔记
JQM进阶:page事件执行过程
jqm入门页面及对话框
windows下mongodb的安装
Bootstarp相关类
兼容性及相关问题总结
浏览器加载和渲染html的顺序
【转】关于top、clientTop、scrollTop、offsetTop等
pl_sql操作--激活提升权限scott用户
-
原文地址:https://www.cnblogs.com/wycBlog/p/7659716.html
Copyright © 2020-2023
润新知