Package com.macrofocus.data.type
Class Base64Coder
java.lang.Object
com.macrofocus.data.type.Base64Coder
-
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]decode(char[] input) Decodes a byte array from Base64 format.static byte[]decode(char[] input, int iOff, int iLen) Decodes a byte array from Base64 format.static byte[]Decodes a byte array from Base64 format.static byte[]Decodes a byte array from Base64 format and ignores line separators, tabs and blanks.static StringDecodes a string from Base64 format.static char[]encode(byte[] input) Encodes a byte array into Base64 format.static char[]encode(byte[] input, int iLen) Encodes a byte array into Base64 format.static char[]encode(byte[] input, int iOff, int iLen) Encodes a byte array into Base64 format.static StringencodeBytes(byte[] bytes) Encodes a string into Base64 format.static StringencodeLines(byte[] input, int iOff, int iLen, int lineLen, String lineSeparator) Encodes a byte array into Base 64 format and breaks the output into lines.static StringEncodes a string into Base64 format.
-
Method Details
-
encodeString
Encodes a string into Base64 format. No blanks or line breaks are inserted.- Parameters:
s- A String to be encoded.- Returns:
- A String containing the Base64 encoded data.
-
encodeBytes
Encodes a string into Base64 format. No blanks or line breaks are inserted.- Parameters:
bytes- A String to be encoded.- Returns:
- A String containing the Base64 encoded data.
-
encodeLines
public static String encodeLines(byte[] input, int iOff, int iLen, int lineLen, String lineSeparator) Encodes a byte array into Base 64 format and breaks the output into lines.- Parameters:
input- An array containing the data bytes to be encoded.iOff- Offset of the first byte ininto be processed.iLen- Number of bytes to be processed inin, starting atiOff.lineLen- Line length for the output data. Should be a multiple of 4.lineSeparator- The line separator to be used to separate the output lines.- Returns:
- A String containing the Base64 encoded data, broken into lines.
-
encode
public static char[] encode(byte[] input) Encodes a byte array into Base64 format. No blanks or line breaks are inserted in the output.- Parameters:
input- An array containing the data bytes to be encoded.- Returns:
- A character array containing the Base64 encoded data.
-
encode
public static char[] encode(byte[] input, int iLen) Encodes a byte array into Base64 format. No blanks or line breaks are inserted in the output.- Parameters:
input- An array containing the data bytes to be encoded.iLen- Number of bytes to process inin.- Returns:
- A character array containing the Base64 encoded data.
-
encode
public static char[] encode(byte[] input, int iOff, int iLen) Encodes a byte array into Base64 format. No blanks or line breaks are inserted in the output.- Parameters:
input- An array containing the data bytes to be encoded.iOff- Offset of the first byte ininto be processed.iLen- Number of bytes to process inin, starting atiOff.- Returns:
- A character array containing the Base64 encoded data.
-
decodeString
Decodes a string from Base64 format. No blanks or line breaks are allowed within the Base64 encoded input data.- Parameters:
s- A Base64 String to be decoded.- Returns:
- A String containing the decoded data.
- Throws:
IllegalArgumentException- If the input is not valid Base64 encoded data.
-
decodeLines
Decodes a byte array from Base64 format and ignores line separators, tabs and blanks. CR, LF, Tab and Space characters are ignored in the input data. This method is compatible withsun.misc.BASE64Decoder.decodeBuffer(String).- Parameters:
s- A Base64 String to be decoded.- Returns:
- An array containing the decoded data bytes.
- Throws:
IllegalArgumentException- If the input is not valid Base64 encoded data.
-
decode
Decodes a byte array from Base64 format. No blanks or line breaks are allowed within the Base64 encoded input data.- Parameters:
s- A Base64 String to be decoded.- Returns:
- An array containing the decoded data bytes.
- Throws:
IllegalArgumentException- If the input is not valid Base64 encoded data.
-
decode
public static byte[] decode(char[] input) Decodes a byte array from Base64 format. No blanks or line breaks are allowed within the Base64 encoded input data.- Parameters:
input- A character array containing the Base64 encoded data.- Returns:
- An array containing the decoded data bytes.
- Throws:
IllegalArgumentException- If the input is not valid Base64 encoded data.
-
decode
public static byte[] decode(char[] input, int iOff, int iLen) Decodes a byte array from Base64 format. No blanks or line breaks are allowed within the Base64 encoded input data.- Parameters:
input- A character array containing the Base64 encoded data.iOff- Offset of the first character ininto be processed.iLen- Number of characters to process inin, starting atiOff.- Returns:
- An array containing the decoded data bytes.
- Throws:
IllegalArgumentException- If the input is not valid Base64 encoded data.
-