mirror of
https://github.com/sheumann/65816-crypto.git
synced 2024-11-28 15:49:27 +00:00
Allow checksumming multiple files, and print filenames with the checksums.
This commit is contained in:
parent
0475dbf132
commit
e288a7bc83
@ -34,18 +34,19 @@ int main(int argc, char **argv) {
|
|||||||
struct concat(HASH_FUNCTION,_context) ctx;
|
struct concat(HASH_FUNCTION,_context) ctx;
|
||||||
FILE *file;
|
FILE *file;
|
||||||
size_t count;
|
size_t count;
|
||||||
int i;
|
int i, n;
|
||||||
|
|
||||||
srand(time(NULL));
|
srand(time(NULL));
|
||||||
|
|
||||||
if (argc != 2) {
|
if (argc < 2) {
|
||||||
fprintf(stderr, "Usage: %s filename\n", argv[0]);
|
fprintf(stderr, "Usage: %s filename ...\n", argv[0]);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
file = fopen(argv[1], "rb");
|
for (n = 1; n < argc; n++) {
|
||||||
|
file = fopen(argv[n], "rb");
|
||||||
if (file == NULL) {
|
if (file == NULL) {
|
||||||
perror(argv[1]);
|
perror(argv[n]);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,7 +71,8 @@ int main(int argc, char **argv) {
|
|||||||
for (i = 0; i < sizeof(ctx.hash); i++) {
|
for (i = 0; i < sizeof(ctx.hash); i++) {
|
||||||
printf("%02x", ctx.hash[i]);
|
printf("%02x", ctx.hash[i]);
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf(" %s\n", argv[n]);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user