[BACK]Return to sha1test.c CVS log [TXT][DIR] Up to [local] / OpenXM / src / ox_ntl / crypt / sha1

Annotation of OpenXM/src/ox_ntl/crypt/sha1/sha1test.c, Revision 1.1

1.1     ! iwane       1: /* $OpenXM$ */
        !             2:
        !             3: /* openssl sha1 ${FILE} */
        !             4:
        !             5: #include <stdio.h>
        !             6:
        !             7: #include "sha1.h"
        !             8:
        !             9: void
        !            10: Usage(char *cmd)
        !            11: {
        !            12:        printf("Usage: %s file\n", cmd);
        !            13:        exit (-1);
        !            14: }
        !            15:
        !            16:
        !            17: int
        !            18: main(int argc, char *argv[])
        !            19: {
        !            20:        FILE *fp;
        !            21:        char buf[1000000];
        !            22:        int ret;
        !            23:        int i;
        !            24:        unsigned char sha[100];
        !            25:
        !            26:        if (argc != 2)
        !            27:                Usage(argv[0]);
        !            28:
        !            29:        fp = fopen(argv[1], "r");
        !            30:        if (fp == NULL) {
        !            31:                fprintf(stderr, "file not found: %s\n", argv[1]);
        !            32:                exit (-1);
        !            33:        }
        !            34:
        !            35:        ret = fread(buf, 1, sizeof(buf), fp);
        !            36:
        !            37:        sha1(sha, (unsigned char *)buf, ret);
        !            38:
        !            39:        fclose(fp);
        !            40:
        !            41:        printf("SHA1(%s)= ", argv[1]);
        !            42:        for (i = 0; i < 20; i++) {
        !            43:                printf("%02x", sha[i] & 0xff);
        !            44:        }
        !            45:        printf("\n");
        !            46:
        !            47:        return (0);
        !            48: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>