Package jodd.util

Class Base64

java.lang.Object
jodd.util.Base64

public class Base64 extends Object
The fastest Base64 encoder/decoder implementations. Base64 is defined in RFC 2045.

Encoding supports two modes - with or without line separator. When line separator flag is on, result will have lines with max size of 76 chars, as per spec.

When decoding, input must be valid, without illegal characters. If input contains lines, they must be 76 chars long. Lines must end with CRLF ("\r\n"), as per spec.

  • Field Details

    • CHARS

      public static final char[] CHARS
    • INV

      private static final int[] INV
  • Constructor Details

    • Base64

      public Base64()
  • Method Details

    • encodeToChar

      public static char[] encodeToChar(byte[] arr, boolean lineSeparator)
      Encodes a raw byte array into a BASE64 char[].
      Parameters:
      lineSeparator - optional CRLF after 76 chars, unless EOF.
    • decode

      public static byte[] decode(char[] arr)
      Decodes a BASE64 encoded char array.
    • encodeToByte

      public static byte[] encodeToByte(String s)
    • encodeToByte

      public static byte[] encodeToByte(String s, boolean lineSep)
    • encodeToByte

      public static byte[] encodeToByte(byte[] arr)
    • encodeToByte

      public static byte[] encodeToByte(byte[] arr, boolean lineSep)
      Encodes a raw byte array into a BASE64 char[].
      Parameters:
      lineSep - optional CRLF after 76 chars, unless EOF.
    • decodeToString

      public static String decodeToString(byte[] arr)
    • decode

      public static byte[] decode(byte[] arr)
      Decodes BASE64 encoded byte array.
    • encodeToString

      public static String encodeToString(String s)
    • encodeToString

      public static String encodeToString(String s, boolean lineSep)
    • encodeToString

      public static String encodeToString(byte[] arr)
    • encodeToString

      public static String encodeToString(byte[] arr, boolean lineSep)
      Encodes a raw byte array into a BASE64 String.
    • decodeToString

      public static String decodeToString(String s)
    • decode

      public static byte[] decode(String s)
      Decodes a BASE64 encoded string.