morpheus-base

morpheus base system
git clone git://git.2f30.org/morpheus-base.git
Log | Files | Refs

md5sum.c (692B)


      1 /* See LICENSE file for copyright and license details. */
      2 #include <stdio.h>
      3 #include <stdlib.h>
      4 #include <stdint.h>
      5 
      6 #include "crypt.h"
      7 #include "md5.h"
      8 #include "util.h"
      9 
     10 static struct md5 s;
     11 struct crypt_ops md5_ops = {
     12 	md5_init,
     13 	md5_update,
     14 	md5_sum,
     15 	&s,
     16 };
     17 
     18 static void
     19 usage(void)
     20 {
     21 	eprintf("usage: %s [-c] [file...]\n", argv0);
     22 }
     23 
     24 int
     25 main(int argc, char *argv[])
     26 {
     27 	uint8_t md[MD5_DIGEST_LENGTH];
     28 	char *checkfile = NULL;
     29 	int cflag = 0;
     30 
     31 	ARGBEGIN {
     32 	case 'c':
     33 		cflag = 1;
     34 		checkfile = ARGF();
     35 		break;
     36 	default:
     37 		usage();
     38 	} ARGEND;
     39 
     40 	if (cflag)
     41 		return cryptcheck(checkfile, argc, argv, &md5_ops, md, sizeof(md));
     42 	return cryptmain(argc, argv, &md5_ops, md, sizeof(md));
     43 }