|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectP2PWNC.Base64
This class provides Base64 encoding and decoding functionality, according to the RCF 2045 specifications.
Field Summary | |
protected static byte[] |
EncTable
Encoding table. |
protected int |
nLineLength
Length of the lines of the base64 encoded text. |
Constructor Summary | |
Base64()
Default constructor. |
|
Base64(int nLineLength)
Sets nLineLength to the specified parameter. |
Method Summary | |
int |
CalculateB64Size(int nDataLen)
Calculates the size of the resulting base64 encoded string. |
int |
CalculateRawSize(java.lang.String b64)
Calculates the size of the raw byte array that will result from a dacoding operation performed on the given string. |
protected void |
DecodeBlock(byte[] in,
byte[] out)
Decodes a 4-byte base64-encoded block to raw bytes. |
(package private) int |
DecodeData(java.lang.String b64,
byte[] raw)
Decodes the base64 input data. |
int |
DecodeFile(java.lang.String infile,
java.lang.String outfile)
Decodes a base64 encoded input file. |
protected void |
EncodeBlock(byte[] in,
byte[] out,
int len)
Encodes a 3-byte block to a 4-byte base64-encoded block. |
(package private) java.lang.String |
EncodeData(byte[] raw,
int datalen)
Base64-encodes a raw byte array of datalen length. |
int |
EncodeFile(java.lang.String infile,
java.lang.String outfile)
Base64-encodes the input file |
static void |
main(java.lang.String[] args)
|
protected boolean |
ShouldBeIgnored(char c)
Returns true if c is a character that should be ignored during the decoding process (that is, tab, space, cr, lf) |
protected B64Data |
TranslateB64(java.lang.String b64data,
int inlen)
Reads base64-encoded data, removes blank/carriage return/linefeed characters |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected int nLineLength
protected static byte[] EncTable
Constructor Detail |
public Base64()
public Base64(int nLineLength)
nLineLength
- int
Length of the lines of the base64 encoded data.Method Detail |
protected boolean ShouldBeIgnored(char c)
c
- char
The character that is to be checked
protected B64Data TranslateB64(java.lang.String b64data, int inlen)
b64data
- Stringinlen
- int
Length of the input data
protected void EncodeBlock(byte[] in, byte[] out, int len)
in
- Input data block. Is is a block of original data that will be converted
to a block of 4 characters.out
- byte[]
Output of the encoding operation on the input block. out is always
a four character byte array.
The four characters which are the result of the encoding operation.len
- int
Length of the original block (in). Legal values are 1, 2, 3.
If len is less than 3 we must pad with =protected void DecodeBlock(byte[] in, byte[] out)
in
- byte[]
4-byte input arrayout
- byte[]
Raw byte array (the result of the decoding operation of 4 bytes).public int CalculateB64Size(int nDataLen)
nDataLen
- int
Length of a raw byte array that will be base64-encoded
public int CalculateRawSize(java.lang.String b64)
b64
- String
A base64 encoded string.
java.lang.String EncodeData(byte[] raw, int datalen)
raw
- byte[]
Input byte array that is to be encoded.datalen
- int
Length of the raw data byte array.
int DecodeData(java.lang.String b64, byte[] raw)
b64
- String
Base64 encoding of raw data.raw
- byte[]
This byte array stores the result of the decoding operation.
public int EncodeFile(java.lang.String infile, java.lang.String outfile)
infile
- String
Path of the file that is to be encoded.outfile
- String
Path of the file where the encoded data will be stored.
public int DecodeFile(java.lang.String infile, java.lang.String outfile)
infile
- String
The path of the base64 encoded input file.outfile
- String
The path of the decoded output file.
public static void main(java.lang.String[] args) throws java.io.IOException
java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |