下面我自己写的代码,把二进制的字符串转为一个大整数,因为本身这个二进制字符串表示的就是一个大整数。 #include <stdio.h> #include <string.h> #define BASE '0' int byte2hex(const char src[], unsigned char dst[], int *length) { int i,j,k; unsigned char temp[8]; if(*length%8 != 0) { printf("Length error,length%8 should be 0!/n"); return -1; } for(i=0,k=0; i< *length; i++) { j = i % 8; temp[j] = ((src[i] - BASE) << (7-j)); if(j == 7) dst[k++] = temp[0]|temp[1]|temp[2]|temp[3]|temp[4]|temp[5]|temp[6]|temp[7]; } *length = *length/8; return 0; } int main() { char* srcx = "000010101110010011000111011110011000101010100000111100010001100101000111000110111110111000