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