blob: 5a1972935748af17278e891dbea81fabf8f0e7f9 (
plain) (
blame)
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
|
#include <stdio.h>
#include <unistd.h>
#include "sha1.h"
int main(void)
{
int i, ret;
SHA1_CTX ctx;
unsigned char digest[SHA1LENGTH];
unsigned char buf[BUFSIZ];
SHA1Init( &ctx );
while(!feof(stdin) && !ferror(stdin)) {
ret = fread(buf, 1, sizeof(buf), stdin);
if (ret)
SHA1Update( &ctx, buf, ret );
}
fclose(stdin);
SHA1Final( digest, &ctx );
for (i = 0; i < SHA1LENGTH; i++)
printf( "%02x", digest[i] );
printf("\n");
return 0;
}
|