⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 md5.c

📁 linux下开发的针对所有磁盘的数据恢复的源码
💻 C
字号:
/*++* NAME*	md5 1* SUMMARY*	compute MD5 signatures* SYNOPSIS*	\fBmd5\fR \fIfile(s)\fR ...* DESCRIPTION*	\fBmd5\fR opens the named \fIfile(s)\fR in order (standard*	input by default) and computes the md5 checksum for each file.**	The output format is one line per file with the checksum and*	corresponding file name separated by whitespace (no file name *	is emitted when reading from standard input).**	This program has a somewhat easier to parse output format*	than the \fBmd5\fR utility found on some UNIX systems.* AUTHOR(S)*	Wietse Venema*	This program is part of SATAN.**	The MD5 implementation used by this program is placed in the *	public domain for free general use by RSA Data Security.*--*/#include <stdio.h>#include "tsk3/libtsk.h"#define MD5_HASH_LENGTH	16intmain(argc, argv)  int argc;  char **argv;{    char *myname = argv[0];    char *crunch();    FILE *fp;    if (argc < 2) {        printf("%s\n", crunch(stdin));    }    else {        while (--argc && *++argv) {            if ((fp = fopen(*argv, "r")) == 0) {                fprintf(stderr, "%s: ", myname);                perror(*argv);                return (1);            }            printf("%s	%s\n", crunch(fp), *argv);            fclose(fp);        }    }    return (0);}char *crunch(fp)  FILE *fp;{    TSK_MD5_CTX md;    unsigned char sum[MD5_HASH_LENGTH];    unsigned char buf[BUFSIZ];    static char result[2 * MD5_HASH_LENGTH + 1];    static char hex[] = "0123456789abcdef";    int buflen;    int i;    TSK_MD5_Init(&md);    while ((buflen = fread(buf, 1, BUFSIZ, fp)) > 0)        TSK_MD5_Update(&md, buf, buflen);    TSK_MD5_Final(sum, &md);    for (i = 0; i < MD5_HASH_LENGTH; i++) {        result[2 * i] = hex[(sum[i] >> 4) & 0xf];        result[2 * i + 1] = hex[sum[i] & 0xf];    }    return (result);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -