gloox 1.0.27
md5.h
1/*
2 Copyright (c) 2006-2023 by Jakob Schröter <js@camaya.net>
3 This file is part of the gloox library. http://camaya.net/gloox
4
5 This software is distributed under a license. The full license
6 agreement can be found in the file LICENSE in this distribution.
7 This software may not be copied, modified, sold or distributed
8 other than expressed in the named license agreement.
9
10 This software is distributed without any warranty.
11*/
12
13/*
14 Copyright (C) 1999, 2002 Aladdin Enterprises. All rights reserved.
15
16 This software is provided 'as-is', without any express or implied
17 warranty. In no event will the authors be held liable for any damages
18 arising from the use of this software.
19
20 Permission is granted to anyone to use this software for any purpose,
21 including commercial applications, and to alter it and redistribute it
22 freely, subject to the following restrictions:
23
24 1. The origin of this software must not be misrepresented; you must not
25 claim that you wrote the original software. If you use this software
26 in a product, an acknowledgment in the product documentation would be
27 appreciated but is not required.
28 2. Altered source versions must be plainly marked as such, and must not be
29 misrepresented as being the original software.
30 3. This notice may not be removed or altered from any source distribution.
31
32 L. Peter Deutsch
33 ghost@aladdin.com
34
35 */
36/* $Id: md5.h,v 1.4 2002/04/13 19:20:28 lpd Exp $ */
37/*
38 Independent implementation of MD5 (RFC 1321).
39
40 This code implements the MD5 Algorithm defined in RFC 1321, whose
41 text is available at
42 http://www.ietf.org/rfc/rfc1321.txt
43 The code is derived from the text of the RFC, including the test suite
44 (section A.5) but excluding the rest of Appendix A. It does not include
45 any code or documentation that is identified in the RFC as being
46 copyrighted.
47
48 The original and principal author of md5.h is L. Peter Deutsch
49 <ghost@aladdin.com>. Other authors are noted in the change history
50 that follows (in reverse chronological order):
51
52 2002-04-13 lpd Removed support for non-ANSI compilers; removed
53 references to Ghostscript; clarified derivation from RFC 1321;
54 now handles byte order either statically or dynamically.
55 1999-11-04 lpd Edited comments slightly for automatic TOC extraction.
56 1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5);
57 added conditionalization for C++ compilation from Martin
58 Purschke <purschke@bnl.gov>.
59 1999-05-03 lpd Original version.
60 */
61
62#ifndef MD5_H__
63#define MD5_H__
64
65#include "macros.h"
66
67#include <string>
68
69namespace gloox
70{
71
81 class GLOOX_API MD5
82 {
83 public:
87 MD5();
88
92 virtual ~MD5();
93
99 void feed( const unsigned char* data, int bytes );
100
105 void feed( const std::string& data );
106
111 void finalize();
112
117 const std::string hex();
118
123 const std::string binary();
124
128 void reset();
129
130 private:
131 struct MD5State
132 {
133 unsigned int count[2]; /* message length in bits, lsw first */
134 unsigned int abcd[4]; /* digest buffer */
135 unsigned char buf[64]; /* accumulate block */
136 } m_state;
137
138 void init();
139 void process( const unsigned char* data );
140
141 static const unsigned char pad[64];
142
143 bool m_finished;
144
145 };
146
147}
148
149#endif // MD5_H__
An MD5 implementation.
Definition: md5.h:82
The namespace for the gloox library.
Definition: adhoc.cpp:28