aboutsummaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2006-10-31 05:41:13 +0000
committerMike Buland <eichlan@xagasoft.com>2006-10-31 05:41:13 +0000
commita67fdaa1ef1e3a5eea88d19e327c05330998e8aa (patch)
tree71897d87312461153c893993ed0582aaa08a9399 /src/tests
parent58cccdbe67f6e1966116b3d2f4c83d77863daadc (diff)
downloadlibbu++-a67fdaa1ef1e3a5eea88d19e327c05330998e8aa.tar.gz
libbu++-a67fdaa1ef1e3a5eea88d19e327c05330998e8aa.tar.bz2
libbu++-a67fdaa1ef1e3a5eea88d19e327c05330998e8aa.tar.xz
libbu++-a67fdaa1ef1e3a5eea88d19e327c05330998e8aa.zip
Added an sha1 class...
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/sha1.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/tests/sha1.cpp b/src/tests/sha1.cpp
new file mode 100644
index 0000000..51c5104
--- /dev/null
+++ b/src/tests/sha1.cpp
@@ -0,0 +1,44 @@
1#include "sha1.h"
2#include "file.h"
3
4#define BS 1024
5
6int main( int argc, char *argv[] )
7{
8 argc--; argv++;
9
10 if( argc == 0 )
11 {
12 printf("Provide a filename.\n");
13 return 0;
14 }
15
16 char buf[BS];
17
18 Sha1 s;
19 File fin( *argv, "rb" );
20 for(;;)
21 {
22 int nRead = fin.read( buf, BS );
23 if( nRead == 0 )
24 break;
25
26 s.update( buf, nRead );
27 if( nRead < BS )
28 break;
29 }
30
31 unsigned char *dig = s.getDigest();
32
33 char val[]={"0123456789ABCDEF"};
34
35 for( int j = 0; j < 20; j++ )
36 {
37 putchar( val[dig[j]>>4] );
38 putchar( val[dig[j]&0x0F] );
39 }
40 putchar('\n');
41
42 delete[] dig;
43}
44