diff options
author | Mike Buland <eichlan@xagasoft.com> | 2007-04-03 03:49:53 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2007-04-03 03:49:53 +0000 |
commit | f4c20290509d7ed3a8fd5304577e7a4cc0b9d974 (patch) | |
tree | 13cdf64f7cf134f397a7165b7a3fe0807e37026b /src/md5.h | |
parent | 74d4c8cd27334fc7204d5a8773deb3d424565778 (diff) | |
download | libbu++-f4c20290509d7ed3a8fd5304577e7a4cc0b9d974.tar.gz libbu++-f4c20290509d7ed3a8fd5304577e7a4cc0b9d974.tar.bz2 libbu++-f4c20290509d7ed3a8fd5304577e7a4cc0b9d974.tar.xz libbu++-f4c20290509d7ed3a8fd5304577e7a4cc0b9d974.zip |
Ok, no code is left in src, it's all in src/old. We'll gradually move code back
into src as it's fixed and re-org'd. This includes tests, which, I may write a
unit test system into libbu++ just to make my life easier.
Diffstat (limited to 'src/md5.h')
-rw-r--r-- | src/md5.h | 81 |
1 files changed, 0 insertions, 81 deletions
diff --git a/src/md5.h b/src/md5.h deleted file mode 100644 index 7f77d83..0000000 --- a/src/md5.h +++ /dev/null | |||
@@ -1,81 +0,0 @@ | |||
1 | #ifndef MD5_H | ||
2 | #define MD5_H | ||
3 | |||
4 | /** | ||
5 | * Used to store an MD5 sum in a handy container. | ||
6 | */ | ||
7 | typedef struct | ||
8 | { | ||
9 | /** The actual data-storage for an MD5 sum. */ | ||
10 | long data[4]; | ||
11 | } md5sum; | ||
12 | |||
13 | /** | ||
14 | * Class for easily calculating MD5 sums of just about any data. | ||
15 | *@author Mike Buland | ||
16 | */ | ||
17 | class md5 | ||
18 | { | ||
19 | public: | ||
20 | /** Build an MD5 sum builder. */ | ||
21 | md5(); | ||
22 | |||
23 | /** Deconstruct */ | ||
24 | virtual ~md5(); | ||
25 | |||
26 | /** | ||
27 | * Create a sum of a standard c string, null terminated. This is probably | ||
28 | * the easiest function to use. | ||
29 | *@param pSum The MD5 sum structure to fill up. | ||
30 | *@param sStr The null-terminated string to turn into an MD5 sum. | ||
31 | */ | ||
32 | void sumString( md5sum *pSum, const char *sStr ); | ||
33 | |||
34 | /** | ||
35 | * Create a sum of an array of arbitrary data. This is the most handy for | ||
36 | * dealing with files and so on. | ||
37 | *@param pSum The MD5 sum structure to fill up. | ||
38 | *@param aData A pointer to the base of the data to sum. | ||
39 | *@param nLen The number of bytes to use in the sum. | ||
40 | */ | ||
41 | void sumData( md5sum *pSum, const char *aData, long nLen ); | ||
42 | |||
43 | /** | ||
44 | * Convert an md5sum to standard hex representation. Make sure that sHex | ||
45 | * contains at least 17 characters of space. | ||
46 | *@param pSum The sum structure to convert to hex. | ||
47 | *@param sHex The string to store the hex value in. | ||
48 | */ | ||
49 | void sumToHex( md5sum *pSum, char *sHex ); | ||
50 | |||
51 | private: | ||
52 | /** | ||
53 | * Do the bulk of the work of the md5 algorithm. | ||
54 | *@param x I'm not sure. I'll need to look it up. | ||
55 | *@param len The length of the data. | ||
56 | *@param output The sum structure to put the output in. | ||
57 | */ | ||
58 | void core_md5( long *x, long len, md5sum *output ); | ||
59 | |||
60 | /** | ||
61 | * Convert an array of charaters to an array of longs in a very crafty way. | ||
62 | * This also applies standard MD5 obfuscation to the resulting array, and | ||
63 | * makes it fit within MD5 size constraints. | ||
64 | *@param str The data to convert. | ||
65 | *@param len The length of the data. | ||
66 | *@param nNewLen A pointer to a variable that will hold the new length of | ||
67 | * the resulting array of longs. | ||
68 | *@returns The newly obfuscated and resized long array. | ||
69 | */ | ||
70 | long *c2l( const char *str, long len, long *nNewLen ); | ||
71 | |||
72 | /** | ||
73 | * Backend helper to convert an array of longs into a hex string. | ||
74 | *@param binarray The binary data to convert. | ||
75 | *@param str The string to store the hex string in. | ||
76 | */ | ||
77 | void l2hexstr( long *binarray, char *str ); | ||
78 | |||
79 | }; | ||
80 | |||
81 | #endif | ||