#include<stdio.h>
#include<string.h>
int str_to_hex(char *string, unsigned char *cbuf, int len)
{
char high, low;
int idx, ii=0;
for (idx=0; idx<len; idx+=3)
{
high = string[idx];
low = string[idx+1];
if(high>='0' && high<='9')
high = high-'0';
else if(high>='A' && high<='F')
high = high - 'A' + 10;
else if(high>='a' && high<='f')
high = high - 'a' + 10;
else
return -1;
if(low>='0' && low<='9')
low = low-'0';
else if(low>='A' && low<='F')
low = low - 'A' + 10;
else if(low>='a' && low<='f')
low = low - 'a' + 10;
else
return -1;
cbuf[ii++] = high<<4 | low;
}
return ii;
}
int main(void)
{
char sendline[1024];
fgets(sendline,1024,stdin);
unsigned char temp[200]={0};
int len = str_to_hex(sendline,temp,strlen(sendline));
for(int i=0;i<len;i++){
printf("%02x ",temp[i]);
}
}
static void hex_to_str(char *ptr,unsigned char *buf,int len)
{
for(int i = 0; i < len; i++)
{
sprintf(ptr, "%02x",buf[i]);
ptr += 2;
}
}