Class Base32
- java.lang.Object
 - 
- org.apache.commons.codec.binary.BaseNCodec
 - 
- org.apache.commons.codec.binary.Base32
 
 
 
- 
- All Implemented Interfaces:
 BinaryDecoder,BinaryEncoder,Decoder,Encoder
public class Base32 extends BaseNCodec
Provides Base32 encoding and decoding as defined by RFC 4648.The class can be parameterized in the following manner with various constructors:
- Whether to use the "base32hex" variant instead of the default "base32"
 - Line length: Default 76. Line length that aren't multiples of 8 will still essentially end up being multiples of 8 in the encoded data.
 - Line separator: Default is CRLF ("\r\n")
 
This class operates directly on byte streams, and not character streams.
This class is thread-safe.
You can configure instances with the
Base32.Builder.Base32 base32 = Base32.builder() .setDecodingPolicy(DecodingPolicy.LENIENT) // default is lenient .setEncodeTable(customEncodeTable) .setLineLength(0) // default is none .setLineSeparator('\r', '\n') // default is CR LF .setPadding('=') // default is = .get()- Since:
 - 1.5
 - See Also:
 - RFC 4648
 
 
- 
- 
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBase32.BuilderBuildsBase32instances.- 
Nested classes/interfaces inherited from class org.apache.commons.codec.binary.BaseNCodec
BaseNCodec.AbstractBuilder<T,B extends BaseNCodec.AbstractBuilder<T,B>> 
 - 
 
- 
Field Summary
- 
Fields inherited from class org.apache.commons.codec.binary.BaseNCodec
MIME_CHUNK_SIZE, PEM_CHUNK_SIZE 
 - 
 
- 
Constructor Summary
Constructors Constructor Description Base32()Constructs a Base32 codec used for decoding and encoding.Base32(boolean useHex)Constructs a Base32 codec used for decoding and encoding.Base32(boolean useHex, byte padding)Constructs a Base32 codec used for decoding and encoding.Base32(byte pad)Constructs a Base32 codec used for decoding and encoding.Base32(int lineLength)Constructs a Base32 codec used for decoding and encoding.Base32(int lineLength, byte[] lineSeparator)Constructs a Base32 codec used for decoding and encoding.Base32(int lineLength, byte[] lineSeparator, boolean useHex)Constructs a Base32 / Base32 Hex codec used for decoding and encoding.Base32(int lineLength, byte[] lineSeparator, boolean useHex, byte padding)Constructs a Base32 / Base32 Hex codec used for decoding and encoding.Base32(int lineLength, byte[] lineSeparator, boolean useHex, byte padding, CodecPolicy decodingPolicy)Constructs a Base32 / Base32 Hex codec used for decoding and encoding. 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Base32.Builderbuilder()Creates a new Builder.booleanisInAlphabet(byte octet)Returns whether or not theoctetis in the Base32 alphabet.- 
Methods inherited from class org.apache.commons.codec.binary.BaseNCodec
decode, decode, decode, encode, encode, encode, encodeAsString, encodeToString, getChunkSeparator, getCodecPolicy, getEncodedLength, isInAlphabet, isInAlphabet, isStrictDecoding 
 - 
 
 - 
 
- 
- 
Constructor Detail
- 
Base32
public Base32()
Constructs a Base32 codec used for decoding and encoding.When encoding the line length is 0 (no chunking).
 
- 
Base32
public Base32(boolean useHex)
Constructs a Base32 codec used for decoding and encoding.When encoding the line length is 0 (no chunking).
- Parameters:
 useHex- iftruethen use Base32 Hex alphabet
 
- 
Base32
public Base32(boolean useHex, byte padding)Constructs a Base32 codec used for decoding and encoding.When encoding the line length is 0 (no chunking).
- Parameters:
 useHex- iftruethen use Base32 Hex alphabetpadding- byte used as padding byte.
 
- 
Base32
public Base32(byte pad)
Constructs a Base32 codec used for decoding and encoding.When encoding the line length is 0 (no chunking).
- Parameters:
 pad- byte used as padding byte.
 
- 
Base32
public Base32(int lineLength)
Constructs a Base32 codec used for decoding and encoding.When encoding the line length is given in the constructor, the line separator is CRLF.
- Parameters:
 lineLength- Each line of encoded data will be at most of the given length (rounded down to the nearest multiple of 8). If lineLength <= 0, then the output will not be divided into lines (chunks). Ignored when decoding.
 
- 
Base32
public Base32(int lineLength, byte[] lineSeparator)Constructs a Base32 codec used for decoding and encoding.When encoding the line length and line separator are given in the constructor.
Line lengths that aren't multiples of 8 will still essentially end up being multiples of 8 in the encoded data.
- Parameters:
 lineLength- Each line of encoded data will be at most of the given length (rounded down to the nearest multiple of 8). If lineLength <= 0, then the output will not be divided into lines (chunks). Ignored when decoding.lineSeparator- Each line of encoded data will end with this sequence of bytes.- Throws:
 java.lang.IllegalArgumentException- Thrown when thelineSeparatorcontains Base32 characters.
 
- 
Base32
public Base32(int lineLength, byte[] lineSeparator, boolean useHex)Constructs a Base32 / Base32 Hex codec used for decoding and encoding.When encoding the line length and line separator are given in the constructor.
Line lengths that aren't multiples of 8 will still essentially end up being multiples of 8 in the encoded data.
- Parameters:
 lineLength- Each line of encoded data will be at most of the given length (rounded down to the nearest multiple of 8). If lineLength <= 0, then the output will not be divided into lines (chunks). Ignored when decoding.lineSeparator- Each line of encoded data will end with this sequence of bytes.useHex- iftrue, then use Base32 Hex alphabet, otherwise use Base32 alphabet- Throws:
 java.lang.IllegalArgumentException- Thrown when thelineSeparatorcontains Base32 characters. Or the lineLength > 0 and lineSeparator is null.
 
- 
Base32
public Base32(int lineLength, byte[] lineSeparator, boolean useHex, byte padding)Constructs a Base32 / Base32 Hex codec used for decoding and encoding.When encoding the line length and line separator are given in the constructor.
Line lengths that aren't multiples of 8 will still essentially end up being multiples of 8 in the encoded data.
- Parameters:
 lineLength- Each line of encoded data will be at most of the given length (rounded down to the nearest multiple of 8). If lineLength <= 0, then the output will not be divided into lines (chunks). Ignored when decoding.lineSeparator- Each line of encoded data will end with this sequence of bytes.useHex- iftrue, then use Base32 Hex alphabet, otherwise use Base32 alphabetpadding- padding byte.- Throws:
 java.lang.IllegalArgumentException- Thrown when thelineSeparatorcontains Base32 characters. Or the lineLength > 0 and lineSeparator is null.
 
- 
Base32
public Base32(int lineLength, byte[] lineSeparator, boolean useHex, byte padding, CodecPolicy decodingPolicy)Constructs a Base32 / Base32 Hex codec used for decoding and encoding.When encoding the line length and line separator are given in the constructor.
Line lengths that aren't multiples of 8 will still essentially end up being multiples of 8 in the encoded data.
- Parameters:
 lineLength- Each line of encoded data will be at most of the given length (rounded down to the nearest multiple of 8). If lineLength <= 0, then the output will not be divided into lines (chunks). Ignored when decoding.lineSeparator- Each line of encoded data will end with this sequence of bytes.useHex- iftrue, then use Base32 Hex alphabet, otherwise use Base32 alphabetpadding- padding byte.decodingPolicy- The decoding policy.- Throws:
 java.lang.IllegalArgumentException- Thrown when thelineSeparatorcontains Base32 characters. Or the lineLength > 0 and lineSeparator is null.- Since:
 - 1.15
 
 
 - 
 
- 
Method Detail
- 
builder
public static Base32.Builder builder()
Creates a new Builder.- Returns:
 - a new Builder.
 - Since:
 - 1.17.0
 
 
- 
isInAlphabet
public boolean isInAlphabet(byte octet)
Returns whether or not theoctetis in the Base32 alphabet.- Parameters:
 octet- The value to test- Returns:
 trueif the value is defined in the Base32 alphabetfalseotherwise.
 
 - 
 
 -