md5: fix test program

This makes the md5-test program print something meaningful and not
smash the stack.

Signed-off-by: Mans Rullgard <mans@mansr.com>
This commit is contained in:
Mans Rullgard 2011-07-03 17:50:38 +01:00
parent ff993cd7fc
commit edf4dbff33

View File

@ -162,21 +162,29 @@ void av_md5_sum(uint8_t *dst, const uint8_t *src, const int len){
}
#ifdef TEST
#include <stdio.h>
#include <inttypes.h>
#undef printf
#include <stdio.h>
static void print_md5(uint8_t *md5)
{
int i;
for (i = 0; i < 16; i++)
printf("%02x", md5[i]);
printf("\n");
}
int main(void){
uint64_t md5val;
uint8_t md5val[16];
int i;
uint8_t in[1000];
for(i=0; i<1000; i++) in[i]= i*i;
av_md5_sum( (uint8_t*)&md5val, in, 1000); printf("%"PRId64"\n", md5val);
av_md5_sum( (uint8_t*)&md5val, in, 63); printf("%"PRId64"\n", md5val);
av_md5_sum( (uint8_t*)&md5val, in, 64); printf("%"PRId64"\n", md5val);
av_md5_sum( (uint8_t*)&md5val, in, 65); printf("%"PRId64"\n", md5val);
av_md5_sum(md5val, in, 1000); print_md5(md5val);
av_md5_sum(md5val, in, 63); print_md5(md5val);
av_md5_sum(md5val, in, 64); print_md5(md5val);
av_md5_sum(md5val, in, 65); print_md5(md5val);
for(i=0; i<1000; i++) in[i]= i % 127;
av_md5_sum( (uint8_t*)&md5val, in, 999); printf("%"PRId64"\n", md5val);
av_md5_sum(md5val, in, 999); print_md5(md5val);
return 0;
}