回复 19 楼 embed_xuel
上面的代码输出是这样的UIN: &UIN=835907249
UIN:
VER=1.1&CMD=Login&SEQ=Thu Jul 17 12:33:20 2014&PS=8d3f0280996672d092acccff7f&M5=1&LC=9326B87B234E7235
void QMD5(const void *encrypt, size_t strlen, unsigned char *md) { MD5_CTX ctx; if (MD5_Init(&ctx) != 1){ fprintf(stderr, "MD5_Init error:%s\n", strerror(errno)); exit(1); } if (MD5_Update(&ctx, encrypt, strlen) != 1){ fprintf(stderr, "MD5_Update error:%s\n", strerror(errno)); exit(1); } if (MD5_Final(md, &ctx) != 1){ fprintf(stderr, "MD5_Final error:%s\n", strerror(errno)); exit(1); } } char encryptpwd[33]; char tmp[3]; time_t tick; unsigned char md[17]; /* Http protocol command string */ char ver[23 + 25] = "VER=1.1&CMD=Login&SEQ="; char seq[25]; char uin[MAXNAME + 5] = "&UIN=835******"; char ps[33 + 6] = "&PS="; char m5[27] = "&M5=1&LC=9326B87B234E7235"; tick = time(0); if (ctime_r(&tick, seq) == NULL) err_quit("ctime_r error"); seq[strlen(seq)-1] = '\0'; QMD5(pwd, strlen(pwd), md); for (i = 0; i < strlen(md); i++) { sprintf(tmp, "%02x", md[i]); strcat(encryptpwd, tmp); } encryptpwd[strlen(encryptpwd)] = '\0'; strcat(ver, seq); printf("UIN: %s\n", uin); //strcat(uin, name); strcat(ps, encryptpwd); printf("UIN: %s\n", uin);