File: sha_driver.c

package info (click to toggle)
tcltrf 2.1.4-dfsg3-2
  • links: PTS
  • area: main
  • in suites: buster, stretch
  • size: 9,652 kB
  • ctags: 9,400
  • sloc: ansic: 73,138; sh: 3,155; tcl: 1,343; makefile: 182; exp: 22
file content (31 lines) | stat: -rw-r--r-- 545 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/* NIST Secure Hash Algorithm */

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include "sha.h"

int main(int argc, char **argv)
{
    FILE *fin;
    SHA_INFO sha_info;

    if (argc < 2) {
	fin = stdin;
	sha_stream(&sha_info, fin);
	sha_print(&sha_info);
    } else {
	while (--argc) {
	    fin = fopen(*(++argv), "rb");
	    if (fin == NULL) {
		printf("error opening %s for reading\n", *argv);
	    } else {
		sha_stream(&sha_info, fin);
		sha_print(&sha_info);
		fclose(fin);
	    }
	}
    }
    return(0);
}