|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--webfunds.util.Base64Coder
This class provides methods for encoding and decoding data in MIME base64 format.
All of the methods either take a byte array, or a String. and return a byte array or String (depending upon the method) containing only the base 64 encoded data. The return value represents a sequence of characters, and depending upon the method, can be either a byte array or String, since these characters are from a subset of both the Unicode and ASCII character repertoires. Base64 encoding encodes 6 binary bits per character, using the characters 'A'-'Z', 'a'-'z', '0'-'9', '+', '/', and '=' (for padding).
References:
Users are Armoury.java and Contract.java.
Repository copied from webfunds/sox/utils/Base64.java at 1.5.
| Field Summary | |
protected static byte[] |
dec_table
Maps the above specific chars back to the 6 bit integer. |
protected static char[] |
enc_table
Maps 6 bit integers to a specific char. |
protected java.lang.String |
newline
The newline used on encodes is by default the system property one. |
protected int |
numGroups
Each line is encoded as numGroups groups, where each group is 4 Base64 letters making up a 3-byte binary sequence. |
| Constructor Summary | |
Base64Coder()
Set up Coder with default paramaters, which are thought to be best for all circumstances (although these are mostly historical...). |
|
| Method Summary | |
static byte[] |
dec(byte[] buf)
Ignores trailing whitespace and newlines |
protected static short |
dec(byte[] ret,
int ret_off,
byte a,
byte b,
byte c,
byte d)
|
byte[] |
decode(byte[] buf)
Decode a Base 64 byte array. |
byte[] |
decode(java.lang.String msg)
Decode a Base 64 string. |
protected static java.lang.String |
enc(byte[] buf,
int numGroups,
java.lang.String nl)
Encodes into numGroups groups, where each group is 4 Base64 letters making up a 3-byte binary sequence. |
java.lang.String |
encode(byte[] buf)
Encode a byte array into Base 64. |
java.lang.String |
encode(java.lang.String s)
Encode a string into Base 64. |
static byte[] |
getDecodeTable()
|
static char[] |
getEncodeTable()
For filtering, etc. |
int |
getMaximumLineLength()
|
java.lang.String |
getNewline()
|
int |
getNumberOfGroups()
|
static void |
main(java.lang.String[] args)
|
void |
setMaximumLineLength(int i)
set the number of Base 64 characters per encoded line |
void |
setNewline(java.lang.String s)
set the newline string sequence for encoding |
void |
setNumberOfGroups(int i)
set the number of groups per encoded line |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Field Detail |
protected java.lang.String newline
protected int numGroups
protected static final char[] enc_table
protected static final byte[] dec_table
| Constructor Detail |
public Base64Coder()
| Method Detail |
public java.lang.String getNewline()
public void setNewline(java.lang.String s)
public int getNumberOfGroups()
public void setNumberOfGroups(int i)
public int getMaximumLineLength()
public void setMaximumLineLength(int i)
public static char[] getEncodeTable()
public static byte[] getDecodeTable()
public java.lang.String encode(byte[] buf)
public java.lang.String encode(java.lang.String s)
public byte[] decode(java.lang.String msg)
public byte[] decode(byte[] buf)
protected static java.lang.String enc(byte[] buf,
int numGroups,
java.lang.String nl)
buf - binary sequence to be encodednumGroups - number of groups to use per linenl - is the newline to be appended to each linepublic static byte[] dec(byte[] buf)
protected static short dec(byte[] ret,
int ret_off,
byte a,
byte b,
byte c,
byte d)
public static void main(java.lang.String[] args)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||