stlab.adobe.com Adobe Systems Incorporated
md5.hpp
Go to the documentation of this file.
1 /*
2  Copyright 2005-2007 Adobe Systems Incorporated and others
3  Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt
4  or a copy at http://stlab.adobe.com/licenses.html)
5 */
6 
7 /*************************************************************************************************/
8 
9 #ifndef ADOBE_MD5_HPP
10 #define ADOBE_MD5_HPP
11 
12 #include <adobe/config.hpp>
13 
14 #include <boost/cstdint.hpp>
15 #include <boost/array.hpp>
16 
17 #include <cstddef>
18 
19 /*************************************************************************************************/
20 
21 /*
22  Relevant copyright information is provided below and may not be removed from this file.
23 
24  Derived from the RSA Data Security, Inc. MD5 Message-Digest Algorithm.
25 */
26 
27 /*************************************************************************************************/
28 
29 /*
30  MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm
31 
32  Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All rights
33  reserved.
34 
35  License to copy and use this software is granted provided that it is
36  identified as the "RSA Data Security, Inc. MD5 Message-Digest Algorithm" in
37  all material mentioning or referencing this software or this function.
38 
39  License is also granted to make and use derivative works provided that such
40  works are identified as "derived from the RSA Data Security, Inc. MD5
41  Message-Digest Algorithm" in all material mentioning or referencing the
42  derived work.
43 
44  RSA Data Security, Inc. makes no representations concerning either the
45  merchantability of this software or the suitability of this software for
46  any particular purpose. It is provided "as is" without express or implied
47  warranty of any kind.
48 
49  These notices must be retained in any copies of any part of this
50  documentation and/or software.
51 */
52 
53 /*************************************************************************************************/
54 
55 namespace adobe {
56 
93 /*************************************************************************************************/
94 
95 class md5_t
96 {
97 public:
98  typedef boost::array<boost::uint8_t, 16> digest_t;
99 
100  md5_t();
101 
102  void update(void* input_block, std::size_t input_length);
103 
104  digest_t final();
105 
106 private:
107  void reset();
108 
109  boost::uint32_t state_m[4]; /* state (ABCD) */
110  boost::uint32_t count_m[2]; /* number of bits, modulo 2^64 (lsb first) */
111  boost::uint8_t buffer_m[64]; /* input buffer */
112 };
113 
114 /*************************************************************************************************/
115 
126 inline md5_t::digest_t md5(void* input_block, std::size_t input_length)
127 {
128  md5_t m;
129 
130  m.update(input_block, input_length);
131 
132  return m.final();
133 }
134 
135 /*************************************************************************************************/
136 
137 } // namespace adobe
138 
139 /*************************************************************************************************/
140 
141 #endif
142 
143 /*************************************************************************************************/

Copyright © 2006-2007 Adobe Systems Incorporated.

Use of this website signifies your agreement to the Terms of Use and Online Privacy Policy.

Search powered by Google