Class Base32
- All Implemented Interfaces:
BinaryDecoder, BinaryEncoder, Decoder, Encoder
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.
To configure a new instance, use a Base32.Builder. For example:
Base32 base32 = Base32.builder()
.setDecodingPolicy(DecodingPolicy.LENIENT) // default is lenient
.setLineLength(0) // default is none
.setLineSeparator('\r', '\n') // default is CR LF
.setPadding('=') // default is '='
.setEncodeTable(customEncodeTable) // default is RFC 4648 Section 6, Table 3: The Base 32 Alphabet
.get()
- Since:
- 1.5
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class BaseNCodec
BaseNCodec.AbstractBuilder<T,B> -
Field Summary
Fields inherited from class BaseNCodec
DECODING_POLICY_DEFAULT, lineLength, MASK_8BITS, MIME_CHUNK_SIZE, pad, PAD, PAD_DEFAULT, PEM_CHUNK_SIZE -
Constructor Summary
ConstructorsConstructorDescriptionBase32()Constructs a Base32 codec used for decoding and encoding.Base32(boolean useHex) Deprecated.Base32(boolean useHex, byte padding) Deprecated.Usebuilder()andBase32.Builder.Base32(byte pad) Deprecated.Usebuilder()andBase32.Builder.Base32(int lineLength) Deprecated.Usebuilder()andBase32.Builder.Base32(int lineLength, byte[] lineSeparator) Deprecated.Usebuilder()andBase32.Builder.Base32(int lineLength, byte[] lineSeparator, boolean useHex) Deprecated.Usebuilder()andBase32.Builder.Base32(int lineLength, byte[] lineSeparator, boolean useHex, byte padding) Deprecated.Usebuilder()andBase32.Builder.Base32(int lineLength, byte[] lineSeparator, boolean useHex, byte padding, CodecPolicy decodingPolicy) Deprecated.Usebuilder()andBase32.Builder. -
Method Summary
Modifier and TypeMethodDescriptionstatic Base32.Builderbuilder()Creates a new Builder.booleanisInAlphabet(byte octet) Returns whether or not theoctetis in the Base32 alphabet.Methods inherited from class BaseNCodec
containsAlphabetOrPad, decode, decode, decode, encode, encode, encode, encodeAsString, encodeToString, ensureBufferSize, getChunkSeparator, getCodecPolicy, getDefaultBufferSize, getEncodedLength, isInAlphabet, isInAlphabet, isStrictDecoding, isWhiteSpace
-
Constructor Details
-
Base32
public Base32()Constructs a Base32 codec used for decoding and encoding.When encoding the line length is 0 (no chunking).
-
Base32
Deprecated.Usebuilder()andBase32.Builder.Constructs a Base32 codec used for decoding and encoding.When encoding the line length is 0 (no chunking).
- Parameters:
useHex-- If true, then use RFC 4648 Section 7, Table 4: Base 32 Encoding with Extended Hex Alphabet
- If false, then use RFC 4648 Section 6, Table 3: The Base 32 Alphabet
-
Base32
Deprecated.Usebuilder()andBase32.Builder.Constructs a Base32 codec used for decoding and encoding.When encoding the line length is 0 (no chunking).
- Parameters:
useHex-- If true, then use RFC 4648 Section 7, Table 4: Base 32 Encoding with Extended Hex Alphabet
- If false, then use RFC 4648 Section 6, Table 3: The Base 32 Alphabet
padding- byte used as padding byte.
-
Base32
Deprecated.Usebuilder()andBase32.Builder.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
Deprecated.Usebuilder()andBase32.Builder.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
Deprecated.Usebuilder()andBase32.Builder.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:
IllegalArgumentException- Thrown when thelineSeparatorcontains Base32 characters.
-
Base32
Deprecated.Usebuilder()andBase32.Builder.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-- If true, then use RFC 4648 Section 7, Table 4: Base 32 Encoding with Extended Hex Alphabet
- If false, then use RFC 4648 Section 6, Table 3: The Base 32 Alphabet
- Throws:
IllegalArgumentException- Thrown when thelineSeparatorcontains Base32 characters. Or the lineLength > 0 and lineSeparator is null.
-
Base32
Deprecated.Usebuilder()andBase32.Builder.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-- If true, then use RFC 4648 Section 7, Table 4: Base 32 Encoding with Extended Hex Alphabet
- If false, then use RFC 4648 Section 6, Table 3: The Base 32 Alphabet
padding- padding byte.- Throws:
IllegalArgumentException- Thrown when thelineSeparatorcontains Base32 characters. Or the lineLength > 0 and lineSeparator is null.
-
Base32
@Deprecated public Base32(int lineLength, byte[] lineSeparator, boolean useHex, byte padding, CodecPolicy decodingPolicy) Deprecated.Usebuilder()andBase32.Builder.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-- If true, then use RFC 4648 Section 7, Table 4: Base 32 Encoding with Extended Hex Alphabet
- If false, then use RFC 4648 Section 6, Table 3: The Base 32 Alphabet
padding- padding byte.decodingPolicy- The decoding policy.- Throws:
IllegalArgumentException- Thrown when thelineSeparatorcontains Base32 characters. Or the lineLength > 0 and lineSeparator is null.- Since:
- 1.15
-
-
Method Details
-
builder
Creates a new Builder.To configure a new instance, use a
Base32.Builder. For example:Base32 base32 = Base32.builder() .setDecodingPolicy(DecodingPolicy.LENIENT) // default is lenient .setLineLength(0) // default is none .setLineSeparator('\r', '\n') // default is CR LF .setPadding('=') // default is '=' .setEncodeTable(customEncodeTable) // default is RFC 4648 Section 6, Table 3: The Base 32 Alphabet .get()- Returns:
- a new Builder.
- Since:
- 1.17.0
-
isInAlphabet
Returns whether or not theoctetis in the Base32 alphabet.- Specified by:
isInAlphabetin classBaseNCodec- Parameters:
octet- The value to test- Returns:
trueif the value is defined in the Base32 alphabetfalseotherwise.
-
builder()andBase32.Builder.