1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
/*******************************************************************
* base64.h
* © Copyright 1995 John Halleck
* All Rights Reserved
*
* ported to c++ by Michael Buesch <mbuesch@freenet.de>
*
* --ABSTRACT-- base64.h
* Do the base 64 encoding as used by PEM and MIME.
*
* --KEYWORDS-- base64.h
*
* --CONTENTS-- base64.h
* Date, Department, Author
* 23nov1994, John Halleck
* Revision history
* For each revision: Date, change summary, authorizing document,
* change department, section, author
* 23nov1994, Initial Creation, John Halleck
* 8apr1995, split library into hex and base64 libraries, John Halleck
* Unit purpose
* (What does this do?)
* [Nothing]
* External Units accessed
* Name, purpose, access summary
* [None]
* Exceptions propagated by this unit
* [None]
* Machine-dependencies
* Access type, purpose, and justification
* [None]
* Compiler-dependencies
* [None]
*********************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License version 2 *
* as published by the Free Software Foundation. *
* *
***************************************************************************/
/***************************************************************************
* copyright (C) 2004 by Ulf Schenk
* This file is originaly based on version 1.0.1 of pwmanager
* and was modified to run on embedded devices that run microkde
*
* $Id$
**************************************************************************/
#ifndef __BASE64_H
#define __BASE64_H
#include <string>
using std::string;
class Base64
{
protected:
struct Base64Ctx
{
int temp; // Working value for input
int bytes; // which input byte we are working on
string buf; // Data buffer
};
public:
Base64() {}
/** run algorithm self test */
static bool selfTest();
/** encode "data" */
string encode(const string &data);
/** decode "data" */
string decode(const string &data);
protected:
/** initialize the context */
void initCtx();
/** finalize the context */
void encFinalizeCtx();
/** finalize the context */
void decFinalizeCtx();
/** encode a character */
void encodeChar(unsigned char c);
/** decode a character */
void decodeChar(char c);
protected:
/** Base64 context */
Base64Ctx ctx;
};
#endif // __BASE64_H
|