aboutsummaryrefslogtreecommitdiff
path: root/src/stable/sha1.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2012-03-25 20:00:08 +0000
committerMike Buland <eichlan@xagasoft.com>2012-03-25 20:00:08 +0000
commit469bbcf0701e1eb8a6670c23145b0da87357e178 (patch)
treeb5b062a16e46a6c5d3410b4e574cd0cc09057211 /src/stable/sha1.h
parentee1b79396076edc4e30aefb285fada03bb45e80d (diff)
downloadlibbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.tar.gz
libbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.tar.bz2
libbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.tar.xz
libbu++-469bbcf0701e1eb8a6670c23145b0da87357e178.zip
Code is all reorganized. We're about ready to release. I should write up a
little explenation of the arrangement.
Diffstat (limited to 'src/stable/sha1.h')
-rw-r--r--src/stable/sha1.h53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/stable/sha1.h b/src/stable/sha1.h
new file mode 100644
index 0000000..1b7f6df
--- /dev/null
+++ b/src/stable/sha1.h
@@ -0,0 +1,53 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#ifndef SHA1_H
9#define SHA1_H
10
11#include <stdint.h>
12#include "bu/cryptohash.h"
13
14namespace Bu
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,
19 * thank you! Check out his website http://tamale.net he has a lot of
20 * cool stuff there.
21 */
22 class Sha1 : public CryptoHash
23 {
24 public:
25 Sha1();
26 virtual ~Sha1();
27
28 virtual void reset();
29 virtual void setSalt( const Bu::String &sSalt );
30 virtual void addData( const void *sData, int iSize );
31 using CryptoHash::addData;
32 virtual String getResult();
33 virtual void writeResult( Stream &sOut );
34
35 void update( const char* data, int num );
36 unsigned char* getDigest();
37
38 // utility methods
39
40 private:
41 static uint32_t lrot( uint32_t x, int bits );
42 static void toBigEndian( uint32_t in, unsigned char* out );
43 void process();
44
45 private:
46 uint32_t uH0, uH1, uH2, uH3, uH4;
47 unsigned char uBytes[64];
48 int iUnprocessedBytes;
49 uint32_t uTotalBytes;
50 };
51};
52
53#endif