blob: df3113ce45bd1f25af2488ddedd91acb42d48ebd (
plain)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
|
#include "sha1.h"
#include "sfile.h"
#define BS 1024
int main( int argc, char *argv[] )
{
argc--; argv++;
if( argc == 0 )
{
printf("Provide a filename.\n");
return 0;
}
char buf[BS];
Sha1 s;
SFile fin( *argv, "rb" );
for(;;)
{
int nRead = fin.read( buf, BS );
if( nRead == 0 )
break;
s.update( buf, nRead );
if( nRead < BS )
break;
}
unsigned char *dig = s.getDigest();
char val[]={"0123456789ABCDEF"};
for( int j = 0; j < 20; j++ )
{
putchar( val[dig[j]>>4] );
putchar( val[dig[j]&0x0F] );
}
putchar('\n');
delete[] dig;
}
|