手机浏览器网页加速器360网站推广官网怎么优化
news/
2025/10/4 14:55:15/
文章来源:
手机浏览器网页加速器,360网站推广官网怎么优化,深圳网站建设培训机构,互动营销案例分析1、BCC异或校验
从输入的HEX第一个字节开始#xff0c;按字节依次循环计算异或值直到HEX结尾字节#xff0c;得到的最终一个字节值。
2、C程序
/*******************************************************************************
_____ ___ ____ ___ _____ _ …1、BCC异或校验
从输入的HEX第一个字节开始按字节依次循环计算异或值直到HEX结尾字节得到的最终一个字节值。
2、C程序
/*******************************************************************************
_____ ___ ____ ___ _____ _ _ _
| ____|_ _| _ \|_ _| |_ _|__(_)_ __ __ _| | | |_ _ __ _
| _| | || |_) || | | |/ __| | _ \ / _ | |_| | | | |/ _ |
| |___ | || _ | | | |\__ \ | | | | (_| | _ | |_| | (_| |
|_____|___|_| \_\___| |_||___/_|_| |_|\__, |_| |_|\__,_|\__,_|* File Name : main.c* Description : This file provides code for bcc caculation in linuxc.* Author : jackwang by jiawang16foxmail.com* Date : 2019-03-09
*******************************************************************************/
/*! -------------------------------------------------------------------------- */
/*! Include headers */
#include stdio.h
#include string.h
#include stdbool.h/*! -------------------------------------------------------------------------- */
/*! Private function declarations */
static unsigned char Char2Int(char chr,bool *isOK);/*! convert char to int type*/
static unsigned char HexStr2Int(char *str, bool *isOK);/*!convert hexstr to int*//*! -------------------------------------------------------------------------- */
/*! main function defination */
int main(int argc, char* argv[])
{int ret 0;int numByte argc; char bccVal 0x00;char inPutbuff[10];bool isOK;int Nibb;if(argc 1){printf([note] no params to caculate, please input hex string, splite by space!\r\n);}else{printf([note] input %d byte: ,numByte-1);for(int i 1; i numByte; i){printf(%s ,argv[i]);}printf(\r\n);for(int i 1; i numByte; i){memcpy(inPutbuff,argv[i],2);Nibb HexStr2Int(inPutbuff,isOK);if(isOK){bccVal ^ (char)Nibb;}}printf(\r\n);printf([note] bcc value: %02X\r\n,bccVal);}return 0;
}/*! -------------------------------------------------------------------------- */
/*! Private function definations */
/*! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
static int Char2Int(char chr,bool *isOK)
{int nibb1;if(chr 0 chr 9){ nibb1 chr - 0; *isOK true;}else if(chr a chr f){ nibb1 chr - a 10; *isOK true;}else if(chr A chr F){ nibb1 chr -A 10; *isOK true; }else{ printf([error] invalid hex str input: %c \r\n,chr); *isOK false; }return nibb1;
}
/*! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
static int HexStr2Int(char *str, bool *isOK)
{int nibb1,nibb2;bool isOK1,isOK2;nibb1 Char2Int(*str, isOK1);nibb2 Char2Int(*(str1),isOK2);if(isOK1 isOK2){*isOK true;return nibb1*16 nibb2;}else{*isOK false;return 0;}
}
3、编译
~$ gcc main.c -o getbcc
4、使用 ~$ ./getbcc 01 02 03 04 11
~$ [note] input 5 byte: 01 02 03 04 11
~$ [note] bcc value: 15
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/927246.shtml
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!