diff options
| author | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2008-11-05 00:08:23 +0100 | 
|---|---|---|
| committer | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2008-11-05 00:08:23 +0100 | 
| commit | 52283ef0ea74c927be29c31ebe9e21ee5d27c739 (patch) | |
| tree | 0fca8ebbc45a61f73ec14adac16e6ccd17850775 /lib | |
| parent | 97f9cb5573f03fa25786b9213a740e875d3b771a (diff) | |
Adding base64 lookup table.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/Base64.cc | 22 | 
1 files changed, 20 insertions, 2 deletions
| diff --git a/lib/Base64.cc b/lib/Base64.cc index af328dc..bb18edc 100644 --- a/lib/Base64.cc +++ b/lib/Base64.cc @@ -20,6 +20,25 @@  #include <Base64.h>  static char cb64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; +static char lookup[] = { +//  x0  x1  x2  x3  x4  x5  x6  x7  x8  x9  xA  xB  xC  xD  xE  xF +     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 0x +     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 1x +     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 62,  0,  0,  0, 63,  // 2x +    52, 53, 54, 55, 56, 57, 58, 59, 60, 61,  0,  0,  0,  0,  0,  0,  // 3x +     0,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14,  // 4x +    15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,  0,  0,  0,  0,  0,  // 5x +     0, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,  // 6x +    41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,  0,  0,  0,  0,  0,  // 7x +     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 8x +     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // 9x +     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // Ax +     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // Bx +     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // Cx +     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // Dx +     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // Ex +     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  // Fx +};  String Base64::encode_block(unsigned char in_tab[3], int len) {      char r[5]; @@ -61,8 +80,7 @@ String Base64::encode(const char * data, int stream_size) {  }  int Base64::stri(char x) { -    char * p = strchr(cb64, x); -    return ((x == '=') || (p == 0)) ? -1 : (p - cb64); +    return lookup[(unsigned char) x];  }  int Base64::decode_block(char s1, char s2, char s3, char s4, unsigned char * out_tab) { | 
