diff options
author | Mike Buland <eichlan@xagasoft.com> | 2012-03-25 20:00:08 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2012-03-25 20:00:08 +0000 |
commit | 469bbcf0701e1eb8a6670c23145b0da87357e178 (patch) | |
tree | b5b062a16e46a6c5d3410b4e574cd0cc09057211 /src/sha1.h | |
parent | ee1b79396076edc4e30aefb285fada03bb45e80d (diff) | |
download | libbu++-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/sha1.h')
-rw-r--r-- | src/sha1.h | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/src/sha1.h b/src/sha1.h deleted file mode 100644 index 1b7f6df..0000000 --- a/src/sha1.h +++ /dev/null | |||
@@ -1,53 +0,0 @@ | |||
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 | |||
14 | namespace 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 | ||