Class Base64

java.lang.Object
com.webmethods.rtl.encode.Base64
Direct Known Subclasses:
Base64

public class Base64 extends Object
Provides Base64 encoding and decoding as defined by RFC 2045.

This class implements section 6.8. Base64 Content-Transfer-Encoding from RFC 2045 Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies by Freed and Borenstein.

Since:
1.0-dev
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static byte[]
    decode(byte[] base64Data)
    Decodes Base64 data into octects
    static byte[]
    encode(byte[] pArray)
    Encodes a byte[] containing binary data, into a byte[] containing characters in the Base64 alphabet.
    static String
    encode(String data)
    Returns the base64 encoding of String.
    static String
    encode(String data, String charEncoding)
    Returns the base64 encoding of String (by first converting to byte[], using the specified charEncoding).
    static byte[]
    encodeBase64(byte[] binaryData)
    Encodes binary data using the base64 algorithm but does not chunk the output.
    static boolean
    isBase64(byte octect)
     
    static boolean
    isBase64(byte[] arrayOctect)
    Tests a given byte array to see if it contains only valid characters within the Base64 alphabet.
    static boolean
    isBase64(String isValidString)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Base64

      public Base64()
  • Method Details

    • isBase64

      public static boolean isBase64(byte octect)
    • isBase64

      public static boolean isBase64(byte[] arrayOctect)
      Tests a given byte array to see if it contains only valid characters within the Base64 alphabet.
      Parameters:
      arrayOctect - byte array to test
      Returns:
      true if all bytes are valid characters in the Base64 alphabet or if the byte array is empty; false, otherwise
    • isBase64

      public static boolean isBase64(String isValidString)
    • encodeBase64

      public static byte[] encodeBase64(byte[] binaryData)
      Encodes binary data using the base64 algorithm but does not chunk the output.
      Parameters:
      binaryData - binary data to encode
      Returns:
      Base64 characters
    • decode

      public static byte[] decode(byte[] base64Data)
      Decodes Base64 data into octects
      Parameters:
      base64Data - Byte array containing Base64 data
      Returns:
      Array containing decoded data.
    • encode

      public static byte[] encode(byte[] pArray)
      Encodes a byte[] containing binary data, into a byte[] containing characters in the Base64 alphabet.
      Parameters:
      pArray - a byte array containing binary data
      Returns:
      A byte array containing only Base64 character data
    • encode

      public static String encode(String data, String charEncoding) throws UnsupportedEncodingException
      Returns the base64 encoding of String (by first converting to byte[], using the specified charEncoding). The return value is also a String. The Default codeEncoding is ISO-8859-1.
      Parameters:
      data - String of data to convert
      charEncoding - the character encoding to use when converting a String to a byte[]
      Returns:
      Base64-encoded String
      Throws:
      UnsupportedEncodingException
    • encode

      public static String encode(String data)
      Returns the base64 encoding of String. First the String is converted to byte[], using the character encoding of ISO-8859-1.
      Parameters:
      data - String of data to convert
      Returns:
      Base64-encoded String