Class Base32Codec

  • All Implemented Interfaces:
    IByteArrayCodec, IByteArrayDecoder, IByteArrayEncoder, IByteArrayStreamDecoder, IByteArrayStreamEncoder, ICodec<byte[]>, IDecoder<byte[],​byte[]>, IEncoder<byte[],​byte[]>

    public class Base32Codec
    extends Object
    implements IByteArrayCodec
    Base32 encoder and decoder based on Apache Commons Codec Base32. Defined in RFC 4648. BASE32 characters are 5 bits in length. They are formed by taking a block of five octets to form a 40-bit string, which is converted into eight BASE32 characters.
    RFC 3548 and defines only the "regular encoding". RFC 4648 adds the "hex encoding". So when using the "regular encoding" it is compliant to both RFCs.
    Source: https://tools.ietf.org/html/rfc4648
    Source: https://tools.ietf.org/html/rfc3548
    Author:
    Philip Helger
    • Constructor Detail

      • Base32Codec

        public Base32Codec()
        Creates a Base32 codec used for decoding and encoding.
      • Base32Codec

        public Base32Codec​(boolean bUseHex)
        Creates a Base32 codec used for decoding and encoding.
        Parameters:
        bUseHex - true to use hex encoding, false to use regular encoding.
    • Method Detail

      • isHexEncoding

        public boolean isHexEncoding()
      • getPad

        public byte getPad()
      • isAddPadding

        public boolean isAddPadding()
      • getMaximumEncodedLength

        public int getMaximumEncodedLength​(int nLen)
        Description copied from interface: IByteArrayEncoder
        Get the maximum encoded length based on the provided decoded length. This is purely for performance reasons. The name of the method would be better called "getMaximumEncodedLength".
        Specified by:
        getMaximumEncodedLength in interface IByteArrayEncoder
        Specified by:
        getMaximumEncodedLength in interface IByteArrayStreamEncoder
        Parameters:
        nLen - The decoded length. Always ≥ 0.
        Returns:
        The maximum encoded length. Always ≥ 0.
      • getMaximumDecodedLength

        public int getMaximumDecodedLength​(int nLen)
        Description copied from interface: IByteArrayDecoder
        Get the maximum decoded length based on the provided encoded length. This is purely for performance reasons.
        Specified by:
        getMaximumDecodedLength in interface IByteArrayDecoder
        Parameters:
        nLen - The encoded length. Always ≥ 0.
        Returns:
        The maximum decoded length. Always ≥ 0.