Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Video AG Infrastruktur
ffworker
Commits
48599eac
Commit
48599eac
authored
Nov 30, 2017
by
Julian Rother
Browse files
Revert "hashfile: replaced md5 with sha256"
This reverts commit
1a06687a
.
parent
68eb93cc
Changes
1
Show whitespace changes
Inline
Side-by-side
util/hashfile.c
View file @
48599eac
...
...
@@ -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
AV
SHA
*
ctx
;
struct
AV
MD5
*
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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment