> ... how to convert this value into the unsigned char array? > ... and why the length is half that of the original array? Each byte is two hex digits, so for input string s and binary array x, with len=strlen(s)/2, it would be something like: for( int i = len-1, j = 0; i >= 0; --i, j += 2) x[i] = 16*hex(s[j]) + hex(s[j+1]); assuming a function hex() to convert one hex digit to binary.