@@ -172,10 +172,10 @@ public Base32() {
172172 * <p>
173173 * When encoding the line length is 0 (no chunking).
174174 * </p>
175- * @param pad byte used as padding byte.
175+ * @param useHex if {@code true} then use Base32 Hex alphabet
176176 */
177- public Base32 (final byte pad ) {
178- this (false , pad );
177+ public Base32 (final boolean useHex ) {
178+ this (0 , null , useHex , PAD_DEFAULT );
179179 }
180180
181181 /**
@@ -184,21 +184,21 @@ public Base32(final byte pad) {
184184 * When encoding the line length is 0 (no chunking).
185185 * </p>
186186 * @param useHex if {@code true} then use Base32 Hex alphabet
187+ * @param padding byte used as padding byte.
187188 */
188- public Base32 (final boolean useHex ) {
189- this (0 , null , useHex , PAD_DEFAULT );
189+ public Base32 (final boolean useHex , final byte padding ) {
190+ this (0 , null , useHex , padding );
190191 }
191192
192193 /**
193194 * Creates a Base32 codec used for decoding and encoding.
194195 * <p>
195196 * When encoding the line length is 0 (no chunking).
196197 * </p>
197- * @param useHex if {@code true} then use Base32 Hex alphabet
198- * @param padding byte used as padding byte.
198+ * @param pad byte used as padding byte.
199199 */
200- public Base32 (final boolean useHex , final byte padding ) {
201- this (0 , null , useHex , padding );
200+ public Base32 (final byte pad ) {
201+ this (false , pad );
202202 }
203203
204204 /**
@@ -587,20 +587,6 @@ public boolean isInAlphabet(final byte octet) {
587587 return octet >= 0 && octet < decodeTable .length && decodeTable [octet ] != -1 ;
588588 }
589589
590- /**
591- * Validates whether decoding allows final trailing characters that cannot be
592- * created during encoding.
593- *
594- * @throws IllegalArgumentException if strict decoding is enabled
595- */
596- private void validateTrailingCharacters () {
597- if (isStrictDecoding ()) {
598- throw new IllegalArgumentException (
599- "Strict decoding: Last encoded character(s) (before the paddings if any) are valid base 32 alphabet but not a possible encoding. " +
600- "Decoding requries either 2, 4, 5, or 7 trailing 5-bit characters to create bytes." );
601- }
602- }
603-
604590 /**
605591 * Validates whether decoding the final trailing character is possible in the context
606592 * of the set of possible base 32 values.
@@ -621,4 +607,18 @@ private void validateCharacter(final long emptyBitsMask, final Context context)
621607 "Expected the discarded bits from the character to be zero." );
622608 }
623609 }
610+
611+ /**
612+ * Validates whether decoding allows final trailing characters that cannot be
613+ * created during encoding.
614+ *
615+ * @throws IllegalArgumentException if strict decoding is enabled
616+ */
617+ private void validateTrailingCharacters () {
618+ if (isStrictDecoding ()) {
619+ throw new IllegalArgumentException (
620+ "Strict decoding: Last encoded character(s) (before the paddings if any) are valid base 32 alphabet but not a possible encoding. " +
621+ "Decoding requries either 2, 4, 5, or 7 trailing 5-bit characters to create bytes." );
622+ }
623+ }
624624}
0 commit comments