调用动态链接库*.so

来源:互联网 发布:数据切片和切块 编辑:程序博客网 时间:2024/05/17 22:26

计算调用程序

#include<stdio.h>int main(void){unsigned charcalc_digest[16] = {0};  // unsigned char *pstr = "abcd";//printf("pstr = %s, sizeof(pstr)=%d\n",pstr,sizeof(pstr));printf("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");unsigned char *ptr;unsigned char auth1[30] = {0};unsigned char auth[48] = {0};auth[0] = 0x02;auth[1] = 0xb7;auth[2] = 0x00;auth[3] = 0x26;auth[4] = 0x6f;auth[5] = 0x63;auth[6] = 0x53;auth[7] = 0xe8;auth[8] = 0x86;auth[9] = 0x14;auth[10] = 0x5e;auth[11] = 0x03;auth[12] = 0x6d;auth[13] = 0x58;auth[14] = 0x1a;auth[15] = 0x24;auth[16] = 0xae;auth[17] = 0x00;auth[18] = 0x2c;auth[19] = 0xdc;auth[20] = 0x06;auth[21] = 0x06;auth[22] = 0x00;auth[23] = 0x00;auth[24] = 0x00;auth[25] = 0x02;auth[26] = 0x08;auth[27] = 0x06;auth[28] = 0xff;auth[29] = 0xff;auth[30] = 0xff;auth[31] = 0xff;auth[32] = 0x09;auth[33] = 0x06;auth[34] = 0xff;auth[35] = 0xff;auth[36] = 0xff;auth[37] = 0x00;auth[38] = 0x74;auth[39] = 0x65;auth[40] = 0x73;auth[41] = 0x74;auth[42] = 0x69;auth[43] = 0x6e;auth[44] = 0x67;auth[45] = 0x31;auth[46] = 0x32;auth[47] = 0x33;//auth[30] ='\0';//unsigned char *aaa = (char *)malloc(31*sizeof(char));//int i;//for(i = 0;i<30;i++)//memcpy(aaa + i, &auth[i],sizeof(char));//*(aaa + 30) = '\0'; //debug(LOG_DEBUG, "Calculating digest on:\n"); for (ptr = (unsigned char *)auth; ptr < ((unsigned char *)auth) + 48; ptr += 32) {char buf[65];int i;buf[0] = '\0';for (i = 0; i < 32; i++) {if (ptr + i >= ((unsigned char *)auth) + 48)break;sprintf(buf + i * 2, "%.2X", ptr[i]);}printf(" buf == %s", buf);//debug(LOG_DEBUG, "%s %d %s",__FUNCTION__,__LINE__,buf);FILE* fp = fopen("/md5_cal.log", "a+");fprintf(fp, "%s %s :Calculating digest on::%s\n",__TIME__,__FUNCTION__,buf);fclose(fp);}printf("\n Calculated digest is:----------:\n");//debug(LOG_DEBUG, "Calculated digest is::\n");rc_md5_calc(calc_digest,(unsigned char *)auth, 48);for (ptr = (unsigned char *)calc_digest; ptr < ((unsigned char *)calc_digest) + 16; ptr += 32) {char buf[65];int i;buf[0] = '\0';for (i = 0; i < 32; i++) {if (ptr + i >= ((unsigned char *)calc_digest) + 16)break;sprintf(buf + i * 2, "%.2X", ptr[i]);}printf(" buf == %s", buf);//debug(LOG_DEBUG, "%s %d %s",__FUNCTION__,__LINE__,buf);FILE* fp = fopen("/md5_cal.log", "a+");    fprintf(fp, "%s %s :Calculated digest is::%s\n\n\n",__TIME__,__FUNCTION__,buf);fclose(fp);}printf("%d\n",add(3,2));//动态链接库 当前目录return 0;}

gcc test.c -o test -L. -lradiusclient-ng -lcalc


原创粉丝点击