MD5: Message-Digest Algorithm 5 信息摘要算法
用途:数字签名防修改;系统保存MD5加密后的密码摘要信息
代码摘抄自openssl库的md5调用,编译方法为gcc -o testmd5 main.c -lcrypto,使用方法为 ./testmd5 文件名
</pre><pre name="code" class="cpp">
#include <openssl/md5.h>
#include <stdio.h>
#include <stdlib.h>
#define BUFSIZE 1024*16
void do_fp(FILE *f);
void pt(unsigned char *md);
int main(int argc, char **argv)
{
int i,err=0;
FILE *IN;
if (argc == 1)
{
do_fp(stdin);
}
else
{
for (i=1; i<argc; i++)
{
IN=fopen(argv[i],"r");
if (IN == NULL)
{
perror(argv[i]);
err++;
continue;
}
printf("MD5(%s)= ",argv[i]);
do_fp(IN);
fclose(IN);
}
}