]> git.sesse.net Git - ffmpeg/blob - libavutil/tests/md5.c
Merge commit 'a6a750c7ef240b72ce01e9653343a0ddf247d196'
[ffmpeg] / libavutil / tests / md5.c
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18
19 #include <stdint.h>
20 #include <stdio.h>
21
22 #include "libavutil/md5.h"
23
24 static void print_md5(uint8_t *md5)
25 {
26     int i;
27     for (i = 0; i < 16; i++)
28         printf("%02x", md5[i]);
29     printf("\n");
30 }
31
32 int main(void)
33 {
34     uint8_t md5val[16];
35     int i;
36     volatile uint8_t in[1000]; // volatile to workaround http://llvm.org/bugs/show_bug.cgi?id=20849
37     // FIXME remove volatile once it has been fixed and all fate clients are updated
38
39     for (i = 0; i < 1000; i++)
40         in[i] = i * i;
41     av_md5_sum(md5val, in, 1000);
42     print_md5(md5val);
43     av_md5_sum(md5val, in, 63);
44     print_md5(md5val);
45     av_md5_sum(md5val, in, 64);
46     print_md5(md5val);
47     av_md5_sum(md5val, in, 65);
48     print_md5(md5val);
49     for (i = 0; i < 1000; i++)
50         in[i] = i % 127;
51     av_md5_sum(md5val, in, 999);
52     print_md5(md5val);
53
54     return 0;
55 }