aboutsummaryrefslogtreecommitdiff
path: root/src/sha1.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2009-02-19 23:44:57 +0000
committerMike Buland <eichlan@xagasoft.com>2009-02-19 23:44:57 +0000
commit4309066dff46f52690998bbd1f60ec8b1631f142 (patch)
tree07b6092622c909351f20590e7ee96d07f5b2d010 /src/sha1.h
parent3f958097632256329cdbaf2219e2ba15325e9c52 (diff)
downloadlibbu++-4309066dff46f52690998bbd1f60ec8b1631f142.tar.gz
libbu++-4309066dff46f52690998bbd1f60ec8b1631f142.tar.bz2
libbu++-4309066dff46f52690998bbd1f60ec8b1631f142.tar.xz
libbu++-4309066dff46f52690998bbd1f60ec8b1631f142.zip
We have the new Bu::CryptoHash base class and Bu::Md5 is here and ready
to rock. sha1 is still only a shell, I dunno if/when I'm going to implement that one. So far Bu::Md5 is 100% compatible with md5sum in all tests performed so far, in fact the test program's output is compatible with md5sum in every way (and it's so cute and little too!) Oh, minor update for stdstream and the formatter, they can handle more handy types now.
Diffstat (limited to 'src/sha1.h')
-rw-r--r--src/sha1.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/sha1.h b/src/sha1.h
new file mode 100644
index 0000000..ab6081d
--- /dev/null
+++ b/src/sha1.h
@@ -0,0 +1,42 @@
1/* sha1.h
2
3Copyright (c) 2005 Michael D. Leonhard
4
5http://tamale.net/
6
7This file is licensed under the terms described in the
8accompanying LICENSE file.
9*/
10
11#ifndef SHA1_H
12#define SHA1_H
13
14#include <stdint.h>
15
16/**
17 * Calculates SHA-1 sums. This is based strongly on code from Michael D.
18 * Leonhard who released his code under the terms of the MIT license, thank you!
19 */
20class Sha1
21{
22public:
23 Sha1();
24 ~Sha1();
25
26 void update( const char* data, int num );
27 unsigned char* getDigest();
28
29 // utility methods
30 static uint32_t lrot( uint32_t x, int bits );
31 static void toBigEndian( uint32_t in, unsigned char* out );
32
33private:
34 // fields
35 uint32_t H0, H1, H2, H3, H4;
36 unsigned char bytes[64];
37 int unprocessedBytes;
38 uint32_t size;
39 void process();
40};
41
42#endif