1个回答
展开全部
先要安装libssl-dev
#include<stdio.h>
#include<openssl/md5.h>
#include<string.h>
int main( int argc, char **argv )
{
unsigned char *data = "123";
unsigned char md[16];
int i;
char tmp[3]={'\0'},buf[33]={'\0'};
MD5(data,strlen(data),md);
for (i = 0; i < 16; i++){
sprintf(tmp,"%2.2x",md[i]);
strcat(buf,tmp);
}
printf("%s\n",buf);
return 0;
}
编译:
# gcc -o 1 1.c -lcrypto
#include<stdio.h>
#include<openssl/md5.h>
#include<string.h>
int main( int argc, char **argv )
{
unsigned char *data = "123";
unsigned char md[16];
int i;
char tmp[3]={'\0'},buf[33]={'\0'};
MD5(data,strlen(data),md);
for (i = 0; i < 16; i++){
sprintf(tmp,"%2.2x",md[i]);
strcat(buf,tmp);
}
printf("%s\n",buf);
return 0;
}
编译:
# gcc -o 1 1.c -lcrypto
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询