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/stable/md5.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/stable/md5.h')
-rw-r--r-- | src/stable/md5.h | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/stable/md5.h b/src/stable/md5.h new file mode 100644 index 0000000..b7597fd --- /dev/null +++ b/src/stable/md5.h | |||
@@ -0,0 +1,54 @@ | |||
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 BU_MD5_H | ||
9 | #define BU_MD5_H | ||
10 | |||
11 | #include "bu/cryptohash.h" | ||
12 | |||
13 | namespace Bu | ||
14 | { | ||
15 | /** | ||
16 | * Class for easily calculating MD5 sums of just about any data. | ||
17 | * This code is based on some public domain code written by Colin Plumb in | ||
18 | * 1993. | ||
19 | *@author Mike Buland | ||
20 | */ | ||
21 | class Md5 : public Bu::CryptoHash | ||
22 | { | ||
23 | public: | ||
24 | /** Build an MD5 sum builder. */ | ||
25 | Md5(); | ||
26 | |||
27 | /** Deconstruct */ | ||
28 | virtual ~Md5(); | ||
29 | |||
30 | virtual void reset(); | ||
31 | virtual void setSalt( const Bu::String &sSalt ); | ||
32 | virtual void addData( const void *sData, int iSize ); | ||
33 | using Bu::CryptoHash::addData; | ||
34 | virtual String getResult(); | ||
35 | virtual void writeResult( Bu::Stream &sOut ); | ||
36 | |||
37 | private: | ||
38 | /** | ||
39 | * Compute one block of input data. | ||
40 | */ | ||
41 | void compBlock( uint32_t *lsum, uint32_t *x ); | ||
42 | void compCap( uint32_t *sumout ); | ||
43 | |||
44 | void _addData( uint8_t *target, int &iCurFill, const void *sData, | ||
45 | int iSize ); | ||
46 | void _toLittleEndian( uint8_t *buf, uint32_t count ); | ||
47 | |||
48 | uint8_t inbuf[64]; | ||
49 | uint32_t sum[4]; | ||
50 | uint32_t uBits[2]; | ||
51 | }; | ||
52 | }; | ||
53 | |||
54 | #endif | ||