MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
coding.hpp
1 /*
2  Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; version 2 of the License.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; see the file COPYING. If not, write to the
15  Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
16  MA 02110-1301 USA.
17 */
18 
19 /* coding.hpp defines hex and base64 encoding/decoing
20 */
21 
22 #ifndef TAO_CRYPT_CODING_HPP
23 #define TAO_CRYPT_CODING_HPP
24 
25 #include "misc.hpp"
26 #include "block.hpp"
27 
28 namespace TaoCrypt {
29 
30 class Source;
31 
32 
33 // Hex Encoding, see RFC 3548
34 class HexEncoder {
35  ByteBlock encoded_;
36  Source& plain_;
37 public:
38  explicit HexEncoder(Source& s) : plain_(s) { Encode(); }
39 private:
40  void Encode();
41 
42  HexEncoder(const HexEncoder&); // hide copy
43  HexEncoder& operator=(const HexEncoder&); // and assign
44 };
45 
46 
47 // Hex Decoding, see RFC 3548
48 class HexDecoder {
49  ByteBlock decoded_;
50  Source& coded_;
51 public:
52  explicit HexDecoder(Source& s) : coded_(s) { Decode(); }
53 private:
54  void Decode();
55 
56  HexDecoder(const HexDecoder&); // hide copy
57  HexDecoder& operator=(const HexDecoder&); // and assign
58 };
59 
60 
61 // Base 64 encoding, see RFC 3548
63  ByteBlock encoded_;
64  Source& plain_;
65 public:
66  explicit Base64Encoder(Source& s) : plain_(s) { Encode(); }
67 private:
68  void Encode();
69 
70  Base64Encoder(const Base64Encoder&); // hide copy
71  Base64Encoder& operator=(const Base64Encoder&); // and assign
72 };
73 
74 
75 // Base 64 decoding, see RFC 3548
77  ByteBlock decoded_;
78  Source& coded_;
79 public:
80  explicit Base64Decoder(Source& s) : coded_(s) { Decode(); }
81 private:
82  void Decode();
83 
84  Base64Decoder(const Base64Decoder&); // hide copy
85  Base64Decoder& operator=(const Base64Decoder&); // and assign
86 };
87 
88 
89 } // namespace
90 
91 #endif // TAO_CRYPT_CODING_HPP