From 48540940b6c28bb4378abfeb500ec45a625b37b6 Mon Sep 17 00:00:00 2001 From: Vadim Dashevskiy Date: Tue, 15 May 2012 10:38:20 +0000 Subject: initial commit git-svn-id: http://svn.miranda-ng.org/main/trunk@2 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/CryptoPP/base64.h | 58 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 plugins/CryptoPP/base64.h (limited to 'plugins/CryptoPP/base64.h') 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 -- cgit v1.2.3