* This class is used to encode and decode data in Base64 format as described in RFC 1521. * *
* Home page: www.source-code.biz
* Author: Christian d'Heureuse, Inventec Informatik AG, Zurich, Switzerland
* Multi-licensed: EPL/LGPL/AL/BSD.
*
*
* Version history:
* 2003-07-22 Christian d'Heureuse (chdh): Module created.
* 2005-08-11 chdh: Lincense changed from GPL to LGPL.
* 2006-11-21 chdh:
* Method encode(String) renamed to encodeString(String).
* Method decode(String) renamed to decodeString(String).
* New method encode(byte[],int) added.
* New method decode(String) added.
* 2009-07-16: Additional licenses (EPL/AL) added.
* 2009-09-16: Additional license (BSD) added.
*/
class Base64Coder {
//Mapping table from 6-bit nibbles to Base64 characters.
private static char[] map1 = new char[64];
static {
int i=0;
for (char c='A'; c<='Z'; c++) map1[i++] = c;
for (char c='a'; c<='z'; c++) map1[i++] = c;
for (char c='0'; c<='9'; c++) map1[i++] = c;
map1[i++] = '+'; map1[i++] = '/';
}
//Mapping table from Base64 characters to 6-bit nibbles.
private static byte[] map2 = new byte[128];
static {
for (int i=0; i