I am placing this code in the Public Domain. Do with it as you will. This software comes with no guarantees or warranties but with plenty of well-wishing instead! Please visit http://iharder.net/base64 periodically to check for updates or to contribute improvements.
| Modifier and Type | Field and Description |
|---|---|
| private static final byte[] | DEC
Translates a Base64 value to either its 6-bit reconstruction value or a negative number indicating some other meaning. |
| private static final byte[] | ENC
The 64 valid Base64 values. |
| private static final byte | EQUALS_SIGN
The equals sign (=) as a byte. |
| private static final byte | EQUALS_SIGN_DEC
Indicates equals sign in encoding. |
| private static final byte | INVALID_DEC
Indicates an invalid byte during decoding. |
| private static final byte | WHITE_SPACE_DEC
Indicates white space in encoding. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static byte[] | Returns: decoded dataThe Base64 encoded data source, int The offset of where to begin decoding off, int The length of characters to decode len)Low-level decoding ASCII characters from a byte array. |
| public static byte[] | |
| private static int | Returns: the number of decoded bytes convertedthe array to convert source, int the index where conversion begins srcOffset, byte[] the array to hold the conversion destination, int the index where output will be put destOffset)Decodes four bytes from array source and writes the resulting bytes (up to three of them) to destination. |
| private static void | encode3to4(byte[]
the array to convert source, int the index where conversion begins srcOffset, int the number of significant bytes in your array numSigBytes, byte[] the array to hold the conversion destination, int the index where output will be put destOffset)Encodes up to three bytes of the array source and writes the resulting four Base64 bytes to destination. |
| public static String | Returns: encoded base64 representation of source.The data to convert source)Encodes a byte array into Base64 notation. |
| public static String | Returns: encoded base64 representation of source.The data to convert source, int Offset in array where conversion should begin off, int Length of data to convert len)Encodes a byte array into Base64 notation. |
| DEC | back to summary |
|---|---|
| private static final byte[] DEC Translates a Base64 value to either its 6-bit reconstruction value or a negative number indicating some other meaning. The table is only 7 bits wide, as the 8th bit is discarded during decoding. | |
| ENC | back to summary |
|---|---|
| private static final byte[] ENC The 64 valid Base64 values. | |
| EQUALS_SIGN | back to summary |
|---|---|
| private static final byte EQUALS_SIGN The equals sign (=) as a byte. | |
| EQUALS_SIGN_DEC | back to summary |
|---|---|
| private static final byte EQUALS_SIGN_DEC Indicates equals sign in encoding. | |
| INVALID_DEC | back to summary |
|---|---|
| private static final byte INVALID_DEC Indicates an invalid byte during decoding. | |
| WHITE_SPACE_DEC | back to summary |
|---|---|
| private static final byte WHITE_SPACE_DEC Indicates white space in encoding. | |
| Base64 | back to summary |
|---|---|
| private Base64() Defeats instantiation. | |
| decode | back to summary |
|---|---|
| public static byte[] decode(byte[] source, int off, int len) Low-level decoding ASCII characters from a byte array.
| |
| decode | back to summary |
|---|---|
| public static byte[] decode(String s) Decodes data from Base64 notation.
| |
| decode4to3 | back to summary |
|---|---|
| private static int decode4to3(byte[] source, int srcOffset, byte[] destination, int destOffset) Decodes four bytes from array source and writes the resulting bytes (up to three of them) to destination. The source and destination arrays can be manipulated anywhere along their length by specifying srcOffset and destOffset. This method does not check to make sure your arrays are large enough to accommodate srcOffset + 4 for the source array or destOffset + 3 for the destination array. This method returns the actual number of bytes that were converted from the Base64 encoding.
| |
| encode3to4 | back to summary |
|---|---|
| private static void encode3to4(byte[] source, int srcOffset, int numSigBytes, byte[] destination, int destOffset) Encodes up to three bytes of the array source and writes the resulting four Base64 bytes to destination. The source and destination arrays can be manipulated anywhere along their length by specifying srcOffset and destOffset. This method does not check to make sure your arrays are large enough to accommodate srcOffset + 3 for the source array or destOffset + 4 for the destination array. The actual number of significant bytes in your array is given by numSigBytes.
| |
| encodeBytes | back to summary |
|---|---|
| public static String encodeBytes(byte[] source) Encodes a byte array into Base64 notation.
| |
| encodeBytes | back to summary |
|---|---|
| public static String encodeBytes(byte[] source, int off, int len) Encodes a byte array into Base64 notation.
| |