Package jadex.common
Class Base64
java.lang.Object
jadex.common.Base64
Base64
Contains lots of utilities for coding and decoding text and character arrays fore and back to the Base64 encoding. It is quite the fastest that I know.
Contains lots of utilities for coding and decoding text and character arrays fore and back to the Base64 encoding. It is quite the fastest that I know.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final byte[]
decode
(byte[] code) This is a wrapper todecode(final byte[] code, final int from, final int len)
static final byte[]
decode
(byte[] src, int from, int len) a copy of the char partstatic final byte[]
decode
(char[] code) This is a wrapper todecode(final char[] code, final int from, final int len)
static final byte[]
decode
(char[] code, int from, int len) This will decode base64 data without line feeds.static final byte[]
decode76
(char[] code) decodeCRLF(code, 0, code.length, 76)
static final byte[]
decodeCRLF
(char[] code, int from, int len) This will decode base64 data with CRLF at 4 character boundary.
The sequence may look like:static final byte[]
decodeCRLF
(char[] code, int from, int len, int llen) This will decode base64 data.static final byte[]
decodeFailSafe
(char[] code) static final byte[]
decodeFailSafe
(char[] code, int from, int len) This removes all bad characters from the char array.static final byte[]
decodeNoPadding
(byte[] code) Decode without padding.static final byte[]
encode
(byte[] text) static final byte[]
encode
(byte[] text, int llen) This will encode the text.static final byte[]
encode
(byte[] text, int from, int len) This will encode the text without line feeds addedstatic final int
encode
(byte[] src, int sstart, int len, byte[] dest, int dstart) This will encode the text without line feeds added.static final byte[]
encodeNoPadding
(byte[] text) Encode and omit padding.static final char[]
toCharArray
(byte[] text) This is a wrapper totoCharArray(final byte[] text, final int from, final int len)
static final char[]
toCharArray
(byte[] text, int llen) This will encode the text.static final char[]
toCharArray
(byte[] text, int from, int len) This will encode the text without line feeds added
-
Constructor Details
-
Base64
public Base64()
-
-
Method Details
-
toCharArray
public static final char[] toCharArray(byte[] text) This is a wrapper totoCharArray(final byte[] text, final int from, final int len)
- Parameters:
text
-- Returns:
- an encoded char array from the text
-
toCharArray
public static final char[] toCharArray(byte[] text, int from, int len) This will encode the text without line feeds added- Parameters:
text
-from
- where to startlen
- how long is the byte array- Returns:
- an encoded char array from the text
-
encodeNoPadding
public static final byte[] encodeNoPadding(byte[] text) Encode and omit padding.- Parameters:
text
-- Returns:
- encoded text
-
encode
public static final byte[] encode(byte[] text) - Parameters:
text
-- Returns:
- encoded text
-
encode
public static final byte[] encode(byte[] text, int from, int len) This will encode the text without line feeds added- Parameters:
text
-from
- where to startlen
- how long is the byte array- Returns:
- an encoded byte array from the text
-
encode
public static final int encode(byte[] src, int sstart, int len, byte[] dest, int dstart) This will encode the text without line feeds added. It will write all output to the dest buffer begining from dstart.
Both src and dest may be the same provided (sstartinvalid input: '<'=dstart).- Parameters:
src
-sstart
- where to startlen
- how long is the byte arraydest
-dstart
-- Returns:
- index to the buffer byte ofter the text
-
toCharArray
public static final char[] toCharArray(byte[] text, int llen) This will encode the text. The CRLF comes afterlb
characters.- Parameters:
text
-llen
- the length of line (without CRLF) must be a multiple of 4- Returns:
- an encoded char array from the text
-
encode
public static final byte[] encode(byte[] text, int llen) This will encode the text. The CRLF comes afterlb
characters.- Parameters:
text
-llen
- the length of line (without CRLF) must be a multiple of 4- Returns:
- an encoded byte array from the text
-
decode
public static final byte[] decode(char[] code) This is a wrapper todecode(final char[] code, final int from, final int len)
- Parameters:
code
-- Returns:
- a byte array holding encoded char data
-
decode
public static final byte[] decode(char[] code, int from, int len) This will decode base64 data without line feeds. The char array should be multiple of 4 in length.- Parameters:
code
-from
- start position in codelen
- length of the part- Returns:
- the decoded sequence of text
-
decodeNoPadding
public static final byte[] decodeNoPadding(byte[] code) Decode without padding.- Parameters:
code
-- Returns:
- a byte array holding encoded char data
-
decode
public static final byte[] decode(byte[] code) This is a wrapper todecode(final byte[] code, final int from, final int len)
- Parameters:
code
-- Returns:
- a byte array holding encoded char data
-
decode
public static final byte[] decode(byte[] src, int from, int len) a copy of the char part- Parameters:
src
-from
-len
-- Returns:
- decoded byte array
-
decode76
public static final byte[] decode76(char[] code) decodeCRLF(code, 0, code.length, 76)
- Parameters:
code
-- Returns:
- the encoded text;
-
decodeCRLF
public static final byte[] decodeCRLF(char[] code, int from, int len, int llen) This will decode base64 data. The starting point and length must be accurate. The data must end on a multiple of 4 boundary and must include the '=' padding, if any.- Parameters:
code
-from
-len
- the length of datallen
- the line length of this base64 (without CRLF)- Returns:
- the decoded sequence of text
-
decodeCRLF
public static final byte[] decodeCRLF(char[] code, int from, int len) This will decode base64 data with CRLF at 4 character boundary.
The sequence may look like:ABCDABCD\r\nABCDABCD or even ABCDABCD#####ABCD###ABCD#ABCD.
The array must be multiple of 4 + number of CRLF or illegal characters and the line length may vary.
- Parameters:
code
-from
-len
-- Returns:
- the decoded sequence of text
-
decodeFailSafe
public static final byte[] decodeFailSafe(char[] code) - Parameters:
code
-- Returns:
- the decoded array
-
decodeFailSafe
public static final byte[] decodeFailSafe(char[] code, int from, int len) This removes all bad characters from the char array. It modifies the array in the scope of the process !!! Than simply calls decode;- Parameters:
code
-from
-len
-- Returns:
- decoded text
-