public class Base32 extends BaseNCodec
The class can be parameterized in the following manner with various constructors:
This class operates directly on byte streams, and not character streams.
This class is thread-safe.
BaseNCodec.ContextCHUNK_SEPARATOR, DECODING_POLICY_DEFAULT, lineLength, MASK_8BITS, MIME_CHUNK_SIZE, pad, PAD, PAD_DEFAULT, PEM_CHUNK_SIZE| 构造器和说明 |
|---|
Base32()
Creates a Base32 codec used for decoding and encoding.
|
Base32(boolean useHex)
Creates a Base32 codec used for decoding and encoding.
|
Base32(boolean useHex,
byte padding)
Creates a Base32 codec used for decoding and encoding.
|
Base32(byte pad)
Creates a Base32 codec used for decoding and encoding.
|
Base32(int lineLength)
Creates a Base32 codec used for decoding and encoding.
|
Base32(int lineLength,
byte[] lineSeparator)
Creates a Base32 codec used for decoding and encoding.
|
Base32(int lineLength,
byte[] lineSeparator,
boolean useHex)
Creates a Base32 / Base32 Hex codec used for decoding and encoding.
|
Base32(int lineLength,
byte[] lineSeparator,
boolean useHex,
byte padding)
Creates a Base32 / Base32 Hex codec used for decoding and encoding.
|
Base32(int lineLength,
byte[] lineSeparator,
boolean useHex,
byte padding,
CodecPolicy decodingPolicy)
Creates a Base32 / Base32 Hex codec used for decoding and encoding.
|
| 限定符和类型 | 方法和说明 |
|---|---|
void |
decode(byte[] input,
int inPos,
int inAvail,
BaseNCodec.Context context)
Decodes all of the provided data, starting at inPos, for inAvail bytes.
|
void |
encode(byte[] input,
int inPos,
int inAvail,
BaseNCodec.Context context)
Encodes all of the provided data, starting at inPos, for inAvail bytes.
|
boolean |
isInAlphabet(byte octet)
Returns whether or not the
octet is in the Base32 alphabet. |
containsAlphabetOrPad, decode, decode, decodeObject, encode, encode, encodeAsString, encodeObject, encodeToString, ensureBufferSize, getDefaultBufferSize, getEncodedLength, isInAlphabet, isInAlphabet, isStrictDecoding, isWhiteSpacepublic Base32()
When encoding the line length is 0 (no chunking).
public Base32(boolean useHex)
When encoding the line length is 0 (no chunking).
useHex - if true then use Base32 Hex alphabetpublic Base32(boolean useHex,
byte padding)
When encoding the line length is 0 (no chunking).
useHex - if true then use Base32 Hex alphabetpadding - byte used as padding byte.public Base32(byte pad)
When encoding the line length is 0 (no chunking).
pad - byte used as padding byte.public Base32(int lineLength)
When encoding the line length is given in the constructor, the line separator is CRLF.
lineLength - Each line of encoded data will be at most of the given length (rounded down to nearest multiple of
8). If lineLength <= 0, then the output will not be divided into lines (chunks). Ignored when
decoding.public Base32(int lineLength,
byte[] lineSeparator)
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.
lineLength - Each line of encoded data will be at most of the given length (rounded down to 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.IllegalArgumentException - Thrown when the lineSeparator contains Base32 characters.public Base32(int lineLength,
byte[] lineSeparator,
boolean useHex)
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.
lineLength - Each line of encoded data will be at most of the given length (rounded down to 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 Base32 Hex alphabet, otherwise use Base32 alphabetIllegalArgumentException - Thrown when the lineSeparator contains Base32 characters. Or the
lineLength > 0 and lineSeparator is null.public Base32(int lineLength,
byte[] lineSeparator,
boolean useHex,
byte padding)
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.
lineLength - Each line of encoded data will be at most of the given length (rounded down to 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 Base32 Hex alphabet, otherwise use Base32 alphabetpadding - byte used as padding byte.IllegalArgumentException - Thrown when the lineSeparator contains Base32 characters. Or the
lineLength > 0 and lineSeparator is null.public Base32(int lineLength,
byte[] lineSeparator,
boolean useHex,
byte padding,
CodecPolicy decodingPolicy)
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.
lineLength - Each line of encoded data will be at most of the given length (rounded down to 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 Base32 Hex alphabet, otherwise use Base32 alphabetpadding - byte used as padding byte.decodingPolicy - The decoding policy.IllegalArgumentException - Thrown when the lineSeparator contains Base32 characters. Or the
lineLength > 0 and lineSeparator is null.public void decode(byte[] input,
int inPos,
int inAvail,
BaseNCodec.Context context)
Decodes all of the provided data, starting at inPos, for inAvail bytes. Should be called at least twice: once with the data to decode, and once with inAvail set to "-1" to alert decoder that EOF has been reached. The "-1" call is not necessary when decoding, but it doesn't hurt, either.
Ignores all non-Base32 characters. This is how chunked (e.g. 76 character) data is handled, since CR and LF are silently ignored, but has implications for other bytes, too. This method subscribes to the garbage-in, garbage-out philosophy: it will not check the provided data for validity.
Output is written to Context#buffer as 8-bit
octets, using Context#pos as the buffer position
decode 在类中 BaseNCodecinput - byte[] array of ascii data to Base32 decode.inPos - Position to start reading data from.inAvail - Amount of bytes available from input for decoding.context - the context to be usedpublic void encode(byte[] input,
int inPos,
int inAvail,
BaseNCodec.Context context)
Encodes all of the provided data, starting at inPos, for inAvail bytes. Must be called at least twice: once with the data to encode, and once with inAvail set to "-1" to alert encoder that EOF has been reached, so flush last remaining bytes (if not multiple of 5).
encode 在类中 BaseNCodecinput - byte[] array of binary data to Base32 encode.inPos - Position to start reading data from.inAvail - Amount of bytes available from input for encoding.context - the context to be usedpublic boolean isInAlphabet(byte octet)
octet is in the Base32 alphabet.isInAlphabet 在类中 BaseNCodecoctet - The value to testtrue if the value is defined in the the Base32 alphabet false otherwise.Copyright © 2022. All rights reserved.