16进制字符串和字节流转换函数
使用查表方法
/*
函数功能:"123456" ==> 0x12,0x34,0x56
输入参数:source 源数据指针
sourceLen 源数据长度
输出参数:dest 输出数据
返回值:正数 输出数据长度;负数 入参错误
*/
int HexStrToByte(const char* source, int sourceLen, unsigned char* dest)
{
int i;
unsigned char highByte, lowByte;
int strlen = 0;
static char _a2iTable[256]={
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 2, 3, 4, 5