sbase

suckless unix tools
git clone git://git.2f30.org/sbase
Log | Files | Refs | README | LICENSE

md5sum.c (728B)


      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 	int ret = 0, (*cryptfunc)(int, char **, struct crypt_ops *, uint8_t *, size_t) = cryptmain;
     28 	uint8_t md[MD5_DIGEST_LENGTH];
     29 
     30 	ARGBEGIN {
     31 	case 'c':
     32 		cryptfunc = cryptcheck;
     33 		break;
     34 	default:
     35 		usage();
     36 	} ARGEND
     37 
     38 	ret |= cryptfunc(argc, argv, &md5_ops, md, sizeof(md));
     39 	ret |= fshut(stdin, "<stdin>") | fshut(stdout, "<stdout>");
     40 
     41 	return ret;
     42 }