1 karl 1.6 //%2004////////////////////////////////////////////////////////////////////////
|
2 karl 1.1 //
|
3 karl 1.6 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
|
6 karl 1.5 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.6 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
|
9 karl 1.1 //
10 // Permission is hereby granted, free of charge, to any person obtaining a copy
|
11 kumpf 1.3 // of this software and associated documentation files (the "Software"), to
12 // deal in the Software without restriction, including without limitation the
13 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
14 karl 1.1 // sell copies of the Software, and to permit persons to whom the Software is
15 // furnished to do so, subject to the following conditions:
16 //
|
17 kumpf 1.3 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
18 karl 1.1 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
19 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
20 kumpf 1.3 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
21 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
23 karl 1.1 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 //
26 //==============================================================================
27 //
28 // Author: Karl Schopmeyer (k.schopmeyer@opengroup.org)
29 //
30 // Modified By:
31 //
32 //%/////////////////////////////////////////////////////////////////////////////
33
34
35 /** This class encodes binary data to base64 Strings and
36 decodes Strings coded in base64 into the corresponding binary
37 data.
38 The base 64 data representation is based on a 64-character alphabet
39 <pre>
40 Table 1: The Base64 Alphabet
41
42 Value Encoding Value Encoding Value Encoding Value Encoding
43 0 A 17 R 34 i 51 z
44 karl 1.1 1 B 18 S 35 j 52 0
45 2 C 19 T 36 k 53 1
46 3 D 20 U 37 l 54 2
47 4 E 21 V 38 m 55 3
48 5 F 22 W 39 n 56 4
49 6 G 23 X 40 o 57 5
50 7 H 24 Y 41 p 58 6
51 8 I 25 Z 42 q 59 7
52 9 J 26 a 43 r 60 8
53 10 K 27 b 44 s 61 9
54 11 L 28 c 45 t 62 +
55 12 M 29 d 46 u 63 /
56 13 N 30 e 47 v
57 14 O 31 f 48 w (pad) =
58 15 P 32 g 49 x
59 16 Q 33 h 50 y
60 </pre>
61 The input file is encoded 6 bits at a time into a single character
62 in the 64-character alphabet. Where padding is required at the end
63 of the file, The padding character is '='.
64 Finally, the output stream should also be broken into lines to improve
65 karl 1.1 human readability. We break it at 76 characters and insert a CR/LF into
66 the stream. This increases the length by less than 3%.
67 Since the decoding ingores characters that are outside the 64 character
68 alphabet, the CR,LF and padding character are dropped.
69 */
70
71 #ifndef Pegasus_Base64_h
72 #define Pegasus_Base64_h
73
74 #include <iostream>
75 #include <fstream>
76 #include <cstring>
77 #include <Pegasus/Common/Config.h>
78 #include <Pegasus/Common/Array.h>
|
79 kumpf 1.4 #include <Pegasus/Common/Linkage.h>
|
80 karl 1.1
81 PEGASUS_NAMESPACE_BEGIN
82
83
84 class PEGASUS_COMMON_LINKAGE Base64
85 {
86 public:
87 /** encode - Encodes a String into a base-64 "string"
88 @param
89 @return String with the endoced data
90 */
91 static Array<Sint8> encode(const Array<Uint8>& vby);
92 /**
93 */
94 static Array<Uint8> decode(const Array<Sint8> str);
95
96 private:
97 static char _Encode(Uint8 uc);
98 static Uint8 _Decode(char c);
99 static Boolean _IsBase64(char c);
100 };
101 karl 1.1
102
103 PEGASUS_NAMESPACE_END
104
105 #endif /* Pegasus_Base64_h */
|