summaryrefslogtreecommitdiff
path: root/plugins/CryptoPP/base64.h
diff options
context:
space:
mode:
authorVadim Dashevskiy <watcherhd@gmail.com>2012-05-15 10:38:20 +0000
committerVadim Dashevskiy <watcherhd@gmail.com>2012-05-15 10:38:20 +0000
commit48540940b6c28bb4378abfeb500ec45a625b37b6 (patch)
tree2ef294c0763e802f91d868bdef4229b6868527de /plugins/CryptoPP/base64.h
parent5c350913f011e119127baeb32a6aedeb4f0d33bc (diff)
initial commit
git-svn-id: http://svn.miranda-ng.org/main/trunk@2 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/CryptoPP/base64.h')
-rw-r--r--plugins/CryptoPP/base64.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/plugins/CryptoPP/base64.h b/plugins/CryptoPP/base64.h
new file mode 100644
index 0000000000..b0756276a3
--- /dev/null
+++ b/plugins/CryptoPP/base64.h
@@ -0,0 +1,58 @@
+#ifndef __BASE_64__
+#define __BASE_64__
+
+#define BPAD '=' /* Padding for odd-sized output */
+#define BERR 0xFF /* Illegal char marker */
+#define BEOF 0x7F /* EOF marker (padding char or EOL) */
+
+typedef unsigned char byte;
+
+static const byte asciiToBin64[] =
+ { BERR, BERR, BERR, BERR, BERR, BERR, BERR, BERR,
+ BERR, BERR, BEOF, BERR, BERR, BEOF, BERR, BERR,
+ BERR, BERR, BERR, BERR, BERR, BERR, BERR, BERR,
+ BERR, BERR, BERR, BERR, BERR, BERR, BERR, BERR,
+ BERR, BERR, BERR, BERR, BERR, BERR, BERR, BERR,
+ BERR, BERR, BERR, 0x3E, BERR, BERR, BERR, 0x3F,
+ 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B,
+ 0x3C, 0x3D, BERR, BERR, BERR, BEOF, BERR, BERR,
+ BERR, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
+ 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E,
+ 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,
+ 0x17, 0x18, 0x19, BERR, BERR, BERR, BERR, BERR,
+ BERR, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20,
+ 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
+ 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30,
+ 0x31, 0x32, 0x33, BERR, BERR, BERR, BERR, BERR,
+ BERR, BERR, BERR, BERR, BERR, BERR, BERR, BERR,
+ BERR, BERR, BERR, BERR, BERR, BERR, BERR, BERR,
+ BERR, BERR, BERR, BERR, BERR, BERR, BERR, BERR,
+ BERR, BERR, BERR, BERR, BERR, BERR, BERR, BERR,
+ BERR, BERR, BERR, BERR, BERR, BERR, BERR, BERR,
+ BERR, BERR, BERR, BERR, BERR, BERR, BERR, BERR,
+ BERR, BERR, BERR, BERR, BERR, BERR, BERR, BERR,
+ BERR, BERR, BERR, BERR, BERR, BERR, BERR, BERR,
+ BERR, BERR, BERR, BERR, BERR, BERR, BERR, BERR,
+ BERR, BERR, BERR, BERR, BERR, BERR, BERR, BERR,
+ BERR, BERR, BERR, BERR, BERR, BERR, BERR, BERR,
+ BERR, BERR, BERR, BERR, BERR, BERR, BERR, BERR,
+ BERR, BERR, BERR, BERR, BERR, BERR, BERR, BERR,
+ BERR, BERR, BERR, BERR, BERR, BERR, BERR, BERR,
+ BERR, BERR, BERR, BERR, BERR, BERR, BERR, BERR,
+ BERR, BERR, BERR, BERR, BERR, BERR, BERR, BERR
+ };
+
+static const byte binToAscii64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+
+char *base64encode(const char *, const int);
+char *base64decode(const char *, int *);
+
+string base64encode(const string);
+string base64decode(const string);
+
+string base64decode(const char *);
+
+#define encode64(data) binToAscii64[data]
+#define decode64(data) asciiToBin64[data]
+
+#endif