Interface BaseNCodec

All Known Implementing Classes:
Base16, Base32, Base64Ext

public interface BaseNCodec
Abstract superclass for Base-N encoders and decoders.
Author:
Leonard Woo
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    bits width
    static final int
    bits per encoded
    static final int
    bytes pre encoded
    static final long
    Mask used to extract 2 bits, used when decoding character.
    static final long
    Mask used to extract 4 bits, used when decoding character.
    static final long
    Mask used to extract 5 bits, used when encoding bytes
    static final long
    Mask used to extract 6 bits, used when encoding bytes
    static final long
    Mask used to extract 8 bits, used in decoding bytes
    static final long
    Mask used to extract the upper 4 bits, used when decoding character.
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    decode(String data)
    Decode the BaseN-encoded data in input and return the data in a new byte array.
    encodeString(byte[] data)
    BaseN-encode the given data and return a newly allocated String with the result.
  • Field Details

    • MASK_8BITS

      static final long MASK_8BITS
      Mask used to extract 8 bits, used in decoding bytes
      See Also:
    • MASK_6BITS

      static final long MASK_6BITS
      Mask used to extract 6 bits, used when encoding bytes
      See Also:
    • MASK_5BITS

      static final long MASK_5BITS
      Mask used to extract 5 bits, used when encoding bytes
      See Also:
    • MASK_4BITS

      static final long MASK_4BITS
      Mask used to extract 4 bits, used when decoding character.
      See Also:
    • MASK_2BITS

      static final long MASK_2BITS
      Mask used to extract 2 bits, used when decoding character.
      See Also:
    • MASK_UPPER_4BITS

      static final long MASK_UPPER_4BITS
      Mask used to extract the upper 4 bits, used when decoding character.
      See Also:
    • BITS_PER_ENCODED_BYTE

      static final int BITS_PER_ENCODED_BYTE
      bits per encoded
      See Also:
    • BYTES_PER_ENCODED_BLOCK

      static final int BYTES_PER_ENCODED_BLOCK
      bytes pre encoded
      See Also:
    • BIT_WIDTH

      static final int BIT_WIDTH
      bits width
      See Also:
  • Method Details

    • encodeString

      String encodeString(byte[] data)
      BaseN-encode the given data and return a newly allocated String with the result.
      Parameters:
      data - the data to encode.
      Returns:
      a newly allocated String with the result.
    • decode

      Decode the BaseN-encoded data in input and return the data in a new byte array.
      Parameters:
      data - the data to decode.
      Returns:
      the data in a new byte array.
      Throws:
      IllegalArgumentException - data something is wrong.
      NullPointerException - data is null.