Commit 48599eac authored by Julian Rother's avatar Julian Rother

Revert "hashfile: replaced md5 with sha256"

This reverts commit 1a06687a.
parent 68eb93cc
......@@ -2,34 +2,34 @@
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <libavutil/sha.h>
#include <libavutil/md5.h>
#include "../util.h"
char *hashfile(char *path)
{
struct AVSHA *ctx;
struct AVMD5 *ctx;
int i, fd;
char *ptr, *buf;
size_t len, size;
FILE *stream;
if ((fd = open(path, O_RDONLY)) < 0)
job_failed("Could not open file for hashing: %s", strerror(errno));
if (!(ctx = av_sha_alloc()))
if (!(ctx = av_md5_alloc()))
exit(99);
av_sha_init(ctx, 256);
av_md5_init(ctx);
buf = xmalloc(4096);
while ((len = read(fd, buf, 4096)) > 0)
av_sha_update(ctx, buf, len);
av_md5_update(ctx, buf, len);
if (len < 0)
job_failed("Could not read file for hashing: %s", strerror(errno));
close(fd);
av_sha_final(ctx, buf);
av_md5_final(ctx, buf);
av_free(ctx);
if (!(stream = open_memstream(&ptr, &size)))
exit(99);
fprintf(stream, "sha256:");
for (i = 0; i < 32; i ++)
fprintf(stream, "md5:");
for (i = 0; i < 16; i ++)
fprintf(stream, "%02hhx", buf[i]);
free(buf);
fclose(stream);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment