LibPkg
md5.h
Go to the documentation of this file.
1 // This file is part of LibPkg.
2 //
3 // Copyright 2003-2020 Graham Shaw
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 
17 #ifndef LIBPKG_MD5
18 #define LIBPKG_MD5
19 
20 #include <cstddef>
21 #include <string>
22 #include <iosfwd>
23 
24 namespace pkg {
25 
26 using std::string;
27 
35 class md5
36 {
37 public:
39  typedef unsigned long uint32;
40 
42  typedef unsigned long long uint64;
43 private:
45  static const int state_size=4;
46 
48  static const int buffer_size=16;
49 
54  uint32 state[state_size];
55 
61  uint32 buffer[buffer_size];
62 
67  uint64 count;
68 
75  void process_buffer();
76 public:
78  md5();
79 
87  void operator()(const void* data,size_t length);
88 
95  void operator()(std::istream& in);
96 
102  void operator()();
103 
112  uint32 operator[](unsigned int index)
113  { return state[index]; }
114 
121  operator string();
122 };
123 
124 }; /* namespace pkg */
125 
126 #endif
unsigned long uint32
A type to represent an unsigned 32-bit integer.
Definition: md5.h:39
The namespace used to hold the package management library.
Definition: auto_dir.cc:23
uint32 operator[](unsigned int index)
Read word from message digest.
Definition: md5.h:112
unsigned long long uint64
A type to represent an unsigned 64-bit integer.
Definition: md5.h:42
A class for producing MD5 message digests.
Definition: md5.h:35
md5()
Construct MD5 object.
Definition: md5.cc:132
void operator()()
Flush buffer.
Definition: md5.cc:260

Reference Manual LibPkg Version 0.9.0 (4 Sep 2020)