aboutsummaryrefslogtreecommitdiff
path: root/src/sha1.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2010-04-23 15:14:00 +0000
committerMike Buland <eichlan@xagasoft.com>2010-04-23 15:14:00 +0000
commit801e7de1f85656746d832508baf4583907826420 (patch)
tree6e2639b6904ee8bcef2781420741124948c17f2c /src/sha1.h
parentd8a8c482b2f6b09ee8995b9563397a9b9bd135e8 (diff)
downloadlibbu++-801e7de1f85656746d832508baf4583907826420.tar.gz
libbu++-801e7de1f85656746d832508baf4583907826420.tar.bz2
libbu++-801e7de1f85656746d832508baf4583907826420.tar.xz
libbu++-801e7de1f85656746d832508baf4583907826420.zip
Minor updates to the List class, unchecked corner cases.
The CsvWriter now writes csv. It understands both excel formatting and c-style, which I made up myself (it's just c-style escape sequences). Sha1 is converted to work with the CryptoHash API and it does indeed work.
Diffstat (limited to 'src/sha1.h')
-rw-r--r--src/sha1.h69
1 files changed, 36 insertions, 33 deletions
diff --git a/src/sha1.h b/src/sha1.h
index 184ba1e..6c6ee37 100644
--- a/src/sha1.h
+++ b/src/sha1.h
@@ -5,45 +5,48 @@
5 * terms of the license contained in the file LICENSE. 5 * terms of the license contained in the file LICENSE.
6 */ 6 */
7 7
8/* sha1.h
9
10Copyright (c) 2005 Michael D. Leonhard
11
12http://tamale.net/
13
14This file is licensed under the terms described in the
15accompanying LICENSE file.
16*/
17
18#ifndef SHA1_H 8#ifndef SHA1_H
19#define SHA1_H 9#define SHA1_H
20 10
21#include <stdint.h> 11#include <stdint.h>
12#include "bu/cryptohash.h"
22 13
23/** 14namespace Bu
24 * Calculates SHA-1 sums. This is based strongly on code from Michael D.
25 * Leonhard who released his code under the terms of the MIT license, thank you!
26 */
27class Sha1
28{ 15{
29public: 16 /**
30 Sha1(); 17 * Calculates SHA-1 sums. This is based strongly on code from Michael D.
31 ~Sha1(); 18 * Leonhard who released his code under the terms of the MIT license,
32 19 * thank you! Check out his website http://tamale.net he has a lot of
33 void update( const char* data, int num ); 20 * cool stuff there.
34 unsigned char* getDigest(); 21 */
35 22 class Sha1 : public CryptoHash
36 // utility methods 23 {
37 static uint32_t lrot( uint32_t x, int bits ); 24 public:
38 static void toBigEndian( uint32_t in, unsigned char* out ); 25 Sha1();
39 26 ~Sha1();
40private: 27
41 // fields 28 virtual void reset();
42 uint32_t H0, H1, H2, H3, H4; 29 virtual void setSalt( const Bu::FString &sSalt );
43 unsigned char bytes[64]; 30 virtual void addData( const void *sData, int iSize );
44 int unprocessedBytes; 31 virtual FString getResult();
45 uint32_t size; 32 virtual void writeResult( Stream &sOut );
46 void process(); 33
34 void update( const char* data, int num );
35 unsigned char* getDigest();
36
37 // utility methods
38
39 private:
40 static uint32_t lrot( uint32_t x, int bits );
41 static void toBigEndian( uint32_t in, unsigned char* out );
42 void process();
43
44 private:
45 uint32_t uH0, uH1, uH2, uH3, uH4;
46 unsigned char uBytes[64];
47 int iUnprocessedBytes;
48 uint32_t uTotalBytes;
49 };
47}; 50};
48 51
49#endif 52#endif