| sha1sum.c - sbase - suckless unix tools | |
| git clone git://git.suckless.org/sbase | |
| Log | |
| Files | |
| Refs | |
| README | |
| LICENSE | |
| --- | |
| sha1sum.c (762B) | |
| --- | |
| 1 /* See LICENSE file for copyright and license details. */ | |
| 2 #include <stdint.h> | |
| 3 #include <stdio.h> | |
| 4 | |
| 5 #include "crypt.h" | |
| 6 #include "sha1.h" | |
| 7 #include "util.h" | |
| 8 | |
| 9 static struct sha1 s; | |
| 10 struct crypt_ops sha1_ops = { | |
| 11 sha1_init, | |
| 12 sha1_update, | |
| 13 sha1_sum, | |
| 14 &s, | |
| 15 }; | |
| 16 | |
| 17 static void | |
| 18 usage(void) | |
| 19 { | |
| 20 eprintf("usage: %s [-c] [file ...]\n", argv0); | |
| 21 } | |
| 22 | |
| 23 int | |
| 24 main(int argc, char *argv[]) | |
| 25 { | |
| 26 int ret = 0, (*cryptfunc)(int, char **, struct crypt_ops *, uint… | |
| 27 uint8_t md[SHA1_DIGEST_LENGTH]; | |
| 28 | |
| 29 ARGBEGIN { | |
| 30 case 'b': | |
| 31 case 't': | |
| 32 /* ignore */ | |
| 33 break; | |
| 34 case 'c': | |
| 35 cryptfunc = cryptcheck; | |
| 36 break; | |
| 37 default: | |
| 38 usage(); | |
| 39 } ARGEND | |
| 40 | |
| 41 ret |= cryptfunc(argc, argv, &sha1_ops, md, sizeof(md)); | |
| 42 ret |= fshut(stdin, "<stdin>") | fshut(stdout, "<stdout>"); | |
| 43 | |
| 44 return ret; | |
| 45 } |