| 334 | |
| 335 | |
| 336 | void file_test(const char* file, byte* check) |
| 337 | { |
| 338 | FILE* f; |
| 339 | int i = 0; |
| 340 | MD5 md5; |
| 341 | byte buf[1024]; |
| 342 | byte md5sum[MD5::DIGEST_SIZE]; |
| 343 | |
| 344 | if( !( f = fopen( file, "rb" ) )) { |
| 345 | printf("Can't open %s\n", file); |
| 346 | return; |
| 347 | } |
| 348 | while( ( i = (int)fread(buf, 1, sizeof(buf), f )) > 0 ) |
| 349 | md5.Update(buf, i); |
| 350 | |
| 351 | md5.Final(md5sum); |
| 352 | memcpy(check, md5sum, sizeof(md5sum)); |
| 353 | |
| 354 | for(int j = 0; j < MD5::DIGEST_SIZE; ++j ) |
| 355 | printf( "%02x", md5sum[j] ); |
| 356 | |
| 357 | printf(" %s\n", file); |
| 358 | |
| 359 | fclose(f); |
| 360 | } |
| 361 | |
| 362 | |
| 363 | int sha_test() |