Package com.lambdaworks.codec
Class Base64
- java.lang.Object
-
- com.lambdaworks.codec.Base64
-
public class Base64 extends java.lang.Object
High-performance base64 codec based on the algorithm used in Mikael Grev's MiG Base64. This implementation is designed to handle base64 without line splitting and with optional padding. Alternative character tables may be supplied to theencode
anddecode
methods to implement modified base64 schemes. Decoding assumes correct input, the caller is responsible for ensuring that the input contains no invalid characters.
-
-
Constructor Summary
Constructors Constructor Description Base64()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]
decode(char[] chars)
Decode base64 chars to bytes.static byte[]
decode(char[] src, int[] table, char pad)
Decode base64 chars to bytes using the supplied decode table and padding character.static char[]
encode(byte[] bytes)
Encode bytes to base64 chars, with padding.static char[]
encode(byte[] bytes, boolean padded)
Encode bytes to base64 chars, with optional padding.static char[]
encode(byte[] src, char[] table, char pad)
Encode bytes to base64 chars using the supplied encode table and with optional padding.
-
-
-
Field Detail
-
encode
private static final char[] encode
-
decode
private static final int[] decode
-
pad
private static final char pad
- See Also:
- Constant Field Values
-
-
Method Detail
-
decode
public static byte[] decode(char[] chars)
Decode base64 chars to bytes.- Parameters:
chars
- Chars to encode.- Returns:
- Decoded bytes.
-
encode
public static char[] encode(byte[] bytes)
Encode bytes to base64 chars, with padding.- Parameters:
bytes
- Bytes to encode.- Returns:
- Encoded chars.
-
encode
public static char[] encode(byte[] bytes, boolean padded)
Encode bytes to base64 chars, with optional padding.- Parameters:
bytes
- Bytes to encode.padded
- Add padding to output.- Returns:
- Encoded chars.
-
decode
public static byte[] decode(char[] src, int[] table, char pad)
Decode base64 chars to bytes using the supplied decode table and padding character.- Parameters:
src
- Base64 encoded data.table
- Decode table.pad
- Padding character.- Returns:
- Decoded bytes.
-
encode
public static char[] encode(byte[] src, char[] table, char pad)
Encode bytes to base64 chars using the supplied encode table and with optional padding.- Parameters:
src
- Bytes to encode.table
- Encoding table.pad
- Padding character, or 0 for no padding.- Returns:
- Encoded chars.
-
-