Class MDfromHTMLBASE64Codec

  • All Implemented Interfaces:
    Serializable

    public class MDfromHTMLBASE64Codec
    extends Object
    implements Serializable
    A home grown Base 64 encoder/decoder that produces and interprets content compatible with other Base 64 codecs from Apache.org and Sun
    Author:
    wnm3
    See Also:
    Serialized Form
    • Field Detail

      • val_safe

        public static final String val_safe
    • Constructor Detail

      • MDfromHTMLBASE64Codec

        public MDfromHTMLBASE64Codec()
    • Method Detail

      • decode

        public static byte[] decode​(String strEncoded)
        Convert a String of BASE64 digits into a byte array, ignoring the equals (=) pad characters at the end. This is not URL safe
        Parameters:
        strEncoded -
        Returns:
        array of Base 256 bytes
      • decode

        public static byte[] decode​(String strEncoded,
                                    boolean bURLSafe)
        Convert a String of BASE64 digits into a byte array, ignoring the equals (=) pad characters at the end. This can be made URL safe by passing in true
        Parameters:
        strEncoded -
        bURLSafe - whether (true) or not (false) the encoding is URL safe meaning it uses "-" and "_" in lieu of "+" and "/"
        Returns:
        array of Base 256 bytes
      • encode

        public static String encode​(byte[] bArray)
        Transform a byte array into a string of the BASE64 characters. Each grouping of 3 bytes is transformed into 4 BASE64 bytes which use 6 bits rather than 8 bits. Pad with equals (=) when input length does not divide by 3 evenly. The resulting String is not URL safe.
        Parameters:
        bArray - Base 256 array of bytes to be encoded
        Returns:
        String of Base 64 bytes containing the encoding of the input array
        See Also:
        encode(byte[], boolean)
      • encode

        public static String encode​(byte[] bArray,
                                    boolean bURLSafe)
        Transform a byte array into a string of the BASE64 characters. Each grouping of 3 bytes is transformed into 4 BASE64 bytes which use 6 bits rather than 8 bits. Pad with equals (=) when intput length does not divide by 3 evenly.
        Parameters:
        bArray - Base 256 array of bytes to be encoded
        bURLSafe - whether (true) or not (false) the encoding is URL safe meaning it uses "-" and "_" in lieu of "+" and "/"
        Returns:
        String of Base 64 bytes containing the encoding of the input array
      • main

        public static void main​(String[] args)