This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-codec.git
commit e620a5e4bcb2326a88f9b854b063619ed186355f Author: Gary Gregory <[email protected]> AuthorDate: Wed Dec 31 08:07:43 2025 -0500 Javadoc --- .../org/apache/commons/codec/binary/Base64.java | 531 +++++++++------------ 1 file changed, 220 insertions(+), 311 deletions(-) diff --git a/src/main/java/org/apache/commons/codec/binary/Base64.java b/src/main/java/org/apache/commons/codec/binary/Base64.java index 352ffdcf..aa8c6baa 100644 --- a/src/main/java/org/apache/commons/codec/binary/Base64.java +++ b/src/main/java/org/apache/commons/codec/binary/Base64.java @@ -24,28 +24,27 @@ import java.util.Objects; import org.apache.commons.codec.CodecPolicy; /** - * Provides Base64 encoding and decoding as defined by <a href="https://www.ietf.org/rfc/rfc2045.txt">RFC 2045</a>. + * Provides Base64 encoding and decoding as defined by <a href="https://www.ietf.org/rfc/rfc2045">RFC 2045 Multipurpose Internet Mail Extensions (MIME) Part + * One: Format of Internet Message Bodies</a> and portions of <a href="https://datatracker.ietf.org/doc/html/rfc4648">RFC 4648 The Base16, Base32, and Base64 + * Data Encodings</a> * * <p> - * This class implements section <cite>6.8. Base64 Content-Transfer-Encoding</cite> from RFC 2045 <cite>Multipurpose - * Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies</cite> by Freed and Borenstein. + * This class implements <a href="https://www.ietf.org/rfc/rfc2045#section-6.8">RFC 2045 6.8. Base64 Content-Transfer-Encoding</a>. * </p> * <p> * The class can be parameterized in the following manner with various constructors: * </p> * <ul> * <li>URL-safe mode: Default off.</li> - * <li>Line length: Default 76. Line length that aren't multiples of 4 will still essentially end up being multiples of - * 4 in the encoded data. - * <li>Line separator: Default is CRLF ("\r\n")</li> + * <li>Line length: Default 76. Line length that aren't multiples of 4 will still essentially end up being multiples of 4 in the encoded data. + * <li>Line separator: Default is CRLF ({@code "\r\n"})</li> * </ul> * <p> * The URL-safe parameter is only applied to encode operations. Decoding seamlessly handles both modes. * </p> * <p> - * Since this class operates directly on byte streams, and not character streams, it is hard-coded to only - * encode/decode character encodings which are compatible with the lower 127 ASCII chart (ISO-8859-1, Windows-1252, - * UTF-8, etc). + * Since this class operates directly on byte streams, and not character streams, it is hard-coded to only encode/decode character encodings which are + * compatible with the lower 127 ASCII chart (ISO-8859-1, Windows-1252, UTF-8, etc). * </p> * <p> * This class is thread-safe. @@ -53,6 +52,7 @@ import org.apache.commons.codec.CodecPolicy; * <p> * To configure a new instance, use a {@link Builder}. For example: * </p> + * * <pre> * Base64 base64 = Base64.builder() * .setDecodingPolicy(DecodingPolicy.LENIENT) // default is lenient, null resets to default @@ -66,7 +66,8 @@ import org.apache.commons.codec.CodecPolicy; * * @see Base64InputStream * @see Base64OutputStream - * @see <a href="https://www.ietf.org/rfc/rfc2045.txt">RFC 2045</a> + * @see <a href="https://www.ietf.org/rfc/rfc2045">RFC 2045 Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies</a> + * @see <a href="https://datatracker.ietf.org/doc/html/rfc4648">RFC 4648 The Base16, Base32, and Base64 Data Encodings</a> * @since 1.0 */ public class Base64 extends BaseNCodec { @@ -110,17 +111,14 @@ public class Base64 extends BaseNCodec { } /** - * Sets the format of the decoding table. - * This method allows to explicitly state whether a "standard" or "URL Safe" Base64 decoding is expected. - * This method does not modify behavior on encoding operations. For configuration of the encoding behavior, - * please use {@link #setUrlSafe} method. + * Sets the format of the decoding table. This method allows to explicitly state whether a "standard" or "URL Safe" Base64 decoding is expected. This + * method does not modify behavior on encoding operations. For configuration of the encoding behavior, please use {@link #setUrlSafe} method. * <p> - * Note: By default, the implementation uses the {@link DecodeTableFormat#MIXED} approach, allowing a - * seamless handling of both {@link DecodeTableFormat#URL_SAFE} and {@link DecodeTableFormat#STANDARD} base64. + * By default, the implementation uses the {@link DecodeTableFormat#MIXED} approach, allowing a seamless handling of both + * {@link DecodeTableFormat#URL_SAFE} and {@link DecodeTableFormat#STANDARD} base64. * </p> * - * @param format table format to be used on Base64 decoding. - * Use {@link DecodeTableFormat#MIXED} or null to reset to the default behavior. + * @param format table format to be used on Base64 decoding. Use {@link DecodeTableFormat#MIXED} or null to reset to the default behavior. * @return {@code this} instance. */ public Builder setDecodeTableFormat(final DecodeTableFormat format) { @@ -148,8 +146,10 @@ public class Base64 extends BaseNCodec { /** * Sets the URL-safe encoding policy. - * This method does not modify behavior on decoding operations. For configuration of the decoding behavior, - * please use {@link #setDecodeTableFormat} method. + * <p> + * This method does not modify behavior on decoding operations. For configuration of the decoding behavior, please use {@link #setDecodeTableFormat} + * method. + * </p> * * @param urlSafe URL-safe encoding policy, null resets to the default. * @return {@code this} instance. @@ -162,28 +162,35 @@ public class Base64 extends BaseNCodec { /** * Defines the Base64 table format to be used on decoding. - * By default, the method uses {@link DecodeTableFormat#MIXED} approach, allowing a seamless handling of - * both {@link DecodeTableFormat#URL_SAFE} and {@link DecodeTableFormat#STANDARD} base64 options. + * <p> + * By default, the method uses {@link DecodeTableFormat#MIXED} approach, allowing a seamless handling of both {@link DecodeTableFormat#URL_SAFE} and + * {@link DecodeTableFormat#STANDARD} base64 options. + * </p> + * + * @since 1.21 */ public enum DecodeTableFormat { /** - * Corresponds to the "standard" Base64 coding table, as specified in Table 1 of RFC 2045. + * Corresponds to the "standard" Base64 coding table, as specified in + * <a href="https://www.ietf.org/rfc/rfc2045#:~:text=Table%201%3A%20The%20Base64%20Alphabet">RFC 2045 Table 1: The Base64 Alphabet</a>. */ STANDARD, /** - * Corresponds to the "URL Safe" Base64 coding table, as specified in Table 2 of RFC 4648. + * Corresponds to the "URL Safe" Base64 coding table, as specified in + * <a href="https://datatracker.ietf.org/doc/html/rfc4648#:~:text=Table%202%3A%20The%20%22URL%20and%20Filename%20safe%22%20Base%2064%20Alphabet">RFC + * 4648 Table 2: The "URL and Filename safe" Base 64 Alphabet</a>. */ URL_SAFE, /** - * Represents a joint approach, allowing a seamless decoding of both character sets, - * corresponding to either Table 1 of RFC 2045 or Table 2 of RFC 4648. - * This decoding table is used by default. + * Represents a joint approach, allowing a seamless decoding of both character sets, corresponding to either + * <a href="https://www.ietf.org/rfc/rfc2045#:~:text=Table%201%3A%20The%20Base64%20Alphabet">RFC 2045 Table 1: The Base64 Alphabet</a> or + * <a href="https://datatracker.ietf.org/doc/html/rfc4648#:~:text=Table%202%3A%20The%20%22URL%20and%20Filename%20safe%22%20Base%2064%20Alphabet">RFC + * 4648 Table 2: The "URL and Filename safe" Base 64 Alphabet</a>. This decoding table is used by default. */ MIXED - } /** @@ -197,8 +204,8 @@ public class Base64 extends BaseNCodec { private static final int DECODING_TABLE_LENGTH = 256; /** - * This array is a lookup table that translates 6-bit positive integer index values into their "Base64 Alphabet" equivalents as specified in Table 1 of RFC - * 2045. + * This array is a lookup table that translates 6-bit positive integer index values into their "Base64 Alphabet" equivalents as specified in + * <a href="https://www.ietf.org/rfc/rfc2045#:~:text=Table%201%3A%20The%20Base64%20Alphabet">RFC 2045 Table 1: The Base64 Alphabet</a>. * <p> * Thanks to "commons" project in ws.apache.org for this code. https://svn.apache.org/repos/asf/webservices/commons/trunk/modules/util/ * </p> @@ -224,17 +231,18 @@ public class Base64 extends BaseNCodec { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', '_' }; // @formatter:on + /** - * This array is a lookup table that translates Unicode characters drawn from the "Base64 Alphabet" (as specified - * in Table 1 of RFC 2045) into their 6-bit positive integer equivalents. Characters that are not in the Base64 - * or Base64 URL Safe alphabets but fall within the bounds of the array are translated to -1. + * This array is a lookup table that translates Unicode characters drawn from the "Base64 Alphabet" (as specified in + * <a href="https://www.ietf.org/rfc/rfc2045#:~:text=Table%201%3A%20The%20Base64%20Alphabet">RFC 2045 Table 1: The Base64 Alphabet</a>) into their 6-bit + * positive integer equivalents. Characters that are not in the Base64 or Base64 URL Safe alphabets but fall within the bounds of the array are translated + * to -1. * <p> - * Note: '+' and '-' both decode to 62. '/' and '_' both decode to 63. This means decoder seamlessly handles both - * URL_SAFE and STANDARD base64. (The encoder, on the other hand, needs to know ahead of time what to emit). + * The characters '+' and '-' both decode to 62. '/' and '_' both decode to 63. This means decoder seamlessly handles both URL_SAFE and STANDARD base64. + * (The encoder, on the other hand, needs to know ahead of time what to emit). * </p> * <p> - * Thanks to "commons" project in ws.apache.org for this code. - * https://svn.apache.org/repos/asf/webservices/commons/trunk/modules/util/ + * Thanks to "commons" project in ws.apache.org for this code. https://svn.apache.org/repos/asf/webservices/commons/trunk/modules/util/ * </p> */ private static final byte[] DECODE_TABLE = { @@ -250,11 +258,10 @@ public class Base64 extends BaseNCodec { }; /** - * This array is a lookup table that translates Unicode characters drawn from the "Base64 Alphabet" (as specified - * in Table 1 of RFC 2045) into their 6-bit positive integer equivalents. Characters that are not in the Base64 - * alphabet but fall within the bounds of the array are translated to -1. - * This decoding table handles only the "standard" base64 characters, such as '+' and '/'. - * The "url-safe" characters such as '-' and '_' are not supported by the table. + * This array is a lookup table that translates Unicode characters drawn from the "Base64 Alphabet" (as specified in + * <a href="https://www.ietf.org/rfc/rfc2045#:~:text=Table%201%3A%20The%20Base64%20Alphabet">RFC 2045 Table 1: The Base64 Alphabet</a>) into their 6-bit + * positive integer equivalents. Characters that are not in the Base64 alphabet but fall within the bounds of the array are translated to -1. This decoding + * table handles only the "standard" base64 characters, such as '+' and '/'. The "url-safe" characters such as '-' and '_' are not supported by the table. */ private static final byte[] STANDARD_DECODE_TABLE = { // 0 1 2 3 4 5 6 7 8 9 A B C D E F @@ -269,12 +276,11 @@ public class Base64 extends BaseNCodec { }; /** - * This array is a lookup table that translates Unicode characters drawn from the "Base64 URL Safe Alphabet" - * (as specified in Table 2 of RFC 4648) into their 6-bit positive integer equivalents. - * Characters that are not in the Base64 URL Safe alphabet but fall within the bounds of the array - * are translated to -1. - * This decoding table handles only the "URL Safe" base64 characters, such as '-' and '_'. - * The "standard" characters such as '+' and '/' are not supported by the table. + * This array is a lookup table that translates Unicode characters drawn from the "Base64 URL Safe Alphabet" (as specified in + * <a href="https://datatracker.ietf.org/doc/html/rfc4648#:~:text=Table%202%3A%20The%20%22URL%20and%20Filename%20safe%22%20Base%2064%20Alphabet">RFC 4648 + * Table 2: The "URL and Filename safe" Base 64 Alphabet</a>) into their 6-bit positive integer equivalents. Characters that are not in the Base64 URL Safe + * alphabet but fall within the bounds of the array are translated to -1. This decoding table handles only the "URL Safe" base64 characters, such as '-' and + * '_'. The "standard" characters such as '+' and '/' are not supported by the table. */ private static final byte[] URL_SAFE_DECODE_TABLE = { // 0 1 2 3 4 5 6 7 8 9 A B C D E F @@ -300,6 +306,7 @@ public class Base64 extends BaseNCodec { /** Mask used to extract 4 bits, used when decoding final trailing character. */ private static final int MASK_4_BITS = 0xf; + /** Mask used to extract 2 bits, used when decoding final trailing character. */ private static final int MASK_2_BITS = 0x3; @@ -331,8 +338,8 @@ public class Base64 extends BaseNCodec { /** * Calculates a decode table for a given encode table. * - * @param encodeTable that is used to determine decode lookup table - * @return decodeTable + * @param encodeTable that is used to determine decode lookup table. + * @return A new decode table. */ private static byte[] calculateDecodeTable(final byte[] encodeTable) { final byte[] decodeTable = new byte[DECODING_TABLE_LENGTH]; @@ -346,14 +353,11 @@ public class Base64 extends BaseNCodec { /** * Decodes Base64 data into octets. * <p> - * <strong>Note:</strong> this method seamlessly handles data encoded in URL-safe or normal mode. - * For enforcing verification against strict standard Base64 or Base64 URL Safe tables, - * please use {@link #decodeBase64Standard} or {@link #decodeBase64Url} methods respectively. - * This method skips any unknown or not supported bytes. + * This method seamlessly handles data encoded in URL-safe or normal mode. For enforcing verification against strict standard Base64 or Base64 URL Safe + * tables, please use {@link #decodeBase64Standard} or {@link #decodeBase64Url} methods respectively. This method skips any unknown or not supported bytes. * </p> * - * @param base64Data - * Byte array containing Base64 data + * @param base64Data Byte array containing Base64 data. * @return New array containing decoded data. */ public static byte[] decodeBase64(final byte[] base64Data) { @@ -363,14 +367,11 @@ public class Base64 extends BaseNCodec { /** * Decodes a Base64 String into octets. * <p> - * <strong>Note:</strong> this method seamlessly handles data encoded in URL-safe or normal mode. - * For enforcing verification against strict standard Base64 or Base64 URL Safe tables, - * please use {@link #decodeBase64Standard} or {@link #decodeBase64Url} methods respectively. - * This method skips any unknown or not supported bytes. + * This method seamlessly handles data encoded in URL-safe or normal mode. For enforcing verification against strict standard Base64 or Base64 URL Safe + * tables, please use {@link #decodeBase64Standard} or {@link #decodeBase64Url} methods respectively. This method skips any unknown or not supported bytes. * </p> * - * @param base64String - * String containing Base64 data + * @param base64String String containing Base64 data. * @return New array containing decoded data. * @since 1.4 */ @@ -381,12 +382,11 @@ public class Base64 extends BaseNCodec { /** * Decodes standard Base64 data into octets. * <p> - * Note: implementation of this method is aligned with the Table 1 of RFC 2045. - * This method skips any unknown or not supported bytes. + * This implementation is aligned with the <a href="https://www.ietf.org/rfc/rfc2045#:~:text=Table%201%3A%20The%20Base64%20Alphabet">RFC 2045 Table 1: The + * Base64 Alphabet</a>. This method skips any unknown or not supported bytes. * </p> * - * @param base64Data - * Byte array containing Base64 data + * @param base64Data Byte array containing Base64 data. * @return New array containing decoded data. * @since 1.21 */ @@ -397,12 +397,11 @@ public class Base64 extends BaseNCodec { /** * Decodes a standard Base64 String into octets. * <p> - * Note: implementation of this method is aligned with the Table 1 of RFC 2045. - * This method skips any unknown or not supported characters. + * This implementation is aligned with the <a href="https://www.ietf.org/rfc/rfc2045#:~:text=Table%201%3A%20The%20Base64%20Alphabet">RFC 2045 Table 1: The + * Base64 Alphabet</a>. This method skips any unknown or not supported characters. * </p> * - * @param base64String - * String containing Base64 data + * @param base64String String containing Base64 data. * @return New array containing decoded data. * @since 1.21 */ @@ -413,12 +412,12 @@ public class Base64 extends BaseNCodec { /** * Decodes URL Safe Base64 data into octets. * <p> - * Note: implementation of this method is aligned with the Table 2 of RFC 4648. - * This method skips any unknown or not supported characters. + * This implementation is aligned with + * <a href="https://datatracker.ietf.org/doc/html/rfc4648#:~:text=Table%202%3A%20The%20%22URL%20and%20Filename%20safe%22%20Base%2064%20Alphabet">RFC 4648 + * Table 2: The "URL and Filename safe" Base 64 Alphabet</a>. This method skips any unknown or not supported characters. * </p> * - * @param base64Data - * Byte array containing Base64 data + * @param base64Data Byte array containing Base64 data. * @return New array containing decoded data. * @since 1.21 */ @@ -429,12 +428,12 @@ public class Base64 extends BaseNCodec { /** * Decodes a URL Safe Base64 String into octets. * <p> - * Note: implementation of this method is aligned with the Table 2 of RFC 4648. - * This method skips any unknown or not supported characters. + * This implementation is aligned with + * <a href="https://datatracker.ietf.org/doc/html/rfc4648#:~:text=Table%202%3A%20The%20%22URL%20and%20Filename%20safe%22%20Base%2064%20Alphabet">RFC 4648 + * Table 2: The "URL and Filename safe" Base 64 Alphabet</a>. This method skips any unknown or not supported characters. * </p> * - * @param base64String - * String containing Base64 data + * @param base64String String containing Base64 data. * @return New array containing decoded data. * @since 1.21 */ @@ -445,9 +444,8 @@ public class Base64 extends BaseNCodec { /** * Decodes a byte64-encoded integer according to crypto standards such as W3C's XML-Signature. * - * @param array - * a byte array containing base64 character data - * @return A BigInteger + * @param array a byte array containing base64 character data. + * @return A BigInteger. * @since 1.4 */ public static BigInteger decodeInteger(final byte[] array) { @@ -457,8 +455,7 @@ public class Base64 extends BaseNCodec { /** * Encodes binary data using the base64 algorithm but does not chunk the output. * - * @param binaryData - * binary data to encode + * @param binaryData binary data to encode. * @return byte[] containing Base64 characters in their UTF-8 representation. */ public static byte[] encodeBase64(final byte[] binaryData) { @@ -468,13 +465,10 @@ public class Base64 extends BaseNCodec { /** * Encodes binary data using the base64 algorithm, optionally chunking the output into 76 character blocks. * - * @param binaryData - * Array containing binary data to encode. - * @param isChunked - * if {@code true} this encoder will chunk the base64 output into 76 character blocks + * @param binaryData Array containing binary data to encode. + * @param isChunked if {@code true} this encoder will chunk the base64 output into 76 character blocks. * @return Base64-encoded data. - * @throws IllegalArgumentException - * Thrown when the input array needs an output array bigger than {@link Integer#MAX_VALUE} + * @throws IllegalArgumentException Thrown when the input array needs an output array bigger than {@link Integer#MAX_VALUE}. */ public static byte[] encodeBase64(final byte[] binaryData, final boolean isChunked) { return encodeBase64(binaryData, isChunked, false); @@ -483,16 +477,12 @@ public class Base64 extends BaseNCodec { /** * Encodes binary data using the base64 algorithm, optionally chunking the output into 76 character blocks. * - * @param binaryData - * Array containing binary data to encode. - * @param isChunked - * if {@code true} this encoder will chunk the base64 output into 76 character blocks - * @param urlSafe - * if {@code true} this encoder will emit - and _ instead of the usual + and / characters. - * <strong>Note: No padding is added when encoding using the URL-safe alphabet.</strong> + * @param binaryData Array containing binary data to encode. + * @param isChunked if {@code true} this encoder will chunk the base64 output into 76 character blocks. + * @param urlSafe if {@code true} this encoder will emit - and _ instead of the usual + and / characters. <strong>No padding is added when encoding using + * the URL-safe alphabet.</strong> * @return Base64-encoded data. - * @throws IllegalArgumentException - * Thrown when the input array needs an output array bigger than {@link Integer#MAX_VALUE} + * @throws IllegalArgumentException Thrown when the input array needs an output array bigger than {@link Integer#MAX_VALUE}. * @since 1.4 */ public static byte[] encodeBase64(final byte[] binaryData, final boolean isChunked, final boolean urlSafe) { @@ -502,22 +492,16 @@ public class Base64 extends BaseNCodec { /** * Encodes binary data using the base64 algorithm, optionally chunking the output into 76 character blocks. * - * @param binaryData - * Array containing binary data to encode. - * @param isChunked - * if {@code true} this encoder will chunk the base64 output into 76 character blocks - * @param urlSafe - * if {@code true} this encoder will emit - and _ instead of the usual + and / characters. - * <strong>Note: No padding is added when encoding using the URL-safe alphabet.</strong> - * @param maxResultSize - * The maximum result size to accept. + * @param binaryData Array containing binary data to encode. + * @param isChunked if {@code true} this encoder will chunk the base64 output into 76 character blocks + * @param urlSafe if {@code true} this encoder will emit - and _ instead of the usual + and / characters. <strong>No padding is added when encoding + * using the URL-safe alphabet.</strong> + * @param maxResultSize The maximum result size to accept. * @return Base64-encoded data. - * @throws IllegalArgumentException - * Thrown when the input array needs an output array bigger than maxResultSize + * @throws IllegalArgumentException Thrown when the input array needs an output array bigger than maxResultSize. * @since 1.4 */ - public static byte[] encodeBase64(final byte[] binaryData, final boolean isChunked, - final boolean urlSafe, final int maxResultSize) { + public static byte[] encodeBase64(final byte[] binaryData, final boolean isChunked, final boolean urlSafe, final int maxResultSize) { if (BinaryCodec.isEmpty(binaryData)) { return binaryData; } @@ -526,10 +510,8 @@ public class Base64 extends BaseNCodec { final Base64 b64 = isChunked ? new Base64(urlSafe) : new Base64(0, CHUNK_SEPARATOR, urlSafe); final long len = b64.getEncodedLength(binaryData); if (len > maxResultSize) { - throw new IllegalArgumentException("Input array too big, the output array would be bigger (" + - len + - ") than the specified maximum size of " + - maxResultSize); + throw new IllegalArgumentException( + "Input array too big, the output array would be bigger (" + len + ") than the specified maximum size of " + maxResultSize); } return b64.encode(binaryData); } @@ -537,9 +519,8 @@ public class Base64 extends BaseNCodec { /** * Encodes binary data using the base64 algorithm and chunks the encoded output into 76 character blocks * - * @param binaryData - * binary data to encode - * @return Base64 characters chunked in 76 character blocks + * @param binaryData binary data to encode. + * @return Base64 characters chunked in 76 character blocks. */ public static byte[] encodeBase64Chunked(final byte[] binaryData) { return encodeBase64(binaryData, true); @@ -547,25 +528,23 @@ public class Base64 extends BaseNCodec { /** * Encodes binary data using the base64 algorithm but does not chunk the output. + * <p> + * <strong> We changed the behavior of this method from multi-line chunking (1.4) to single-line non-chunking (1.5).</strong> + * </p> * - * NOTE: We changed the behavior of this method from multi-line chunking (commons-codec-1.4) to - * single-line non-chunking (commons-codec-1.5). - * - * @param binaryData - * binary data to encode + * @param binaryData binary data to encode * @return String containing Base64 characters. - * @since 1.4 (NOTE: 1.4 chunked the output, whereas 1.5 does not). + * @since 1.4 (NOTE: 1.4 chunked the output, whereas 1.5 does not). */ public static String encodeBase64String(final byte[] binaryData) { return StringUtils.newStringUsAscii(encodeBase64(binaryData, false)); } /** - * Encodes binary data using a URL-safe variation of the base64 algorithm but does not chunk the output. The - * url-safe variation emits - and _ instead of + and / characters. - * <strong>Note: No padding is added.</strong> - * @param binaryData - * binary data to encode + * Encodes binary data using a URL-safe variation of the base64 algorithm but does not chunk the output. The url-safe variation emits - and _ instead of + + * and / characters. <strong>No padding is added.</strong> + * + * @param binaryData binary data to encode. * @return byte[] containing Base64 characters in their UTF-8 representation. * @since 1.4 */ @@ -574,12 +553,11 @@ public class Base64 extends BaseNCodec { } /** - * Encodes binary data using a URL-safe variation of the base64 algorithm but does not chunk the output. The - * url-safe variation emits - and _ instead of + and / characters. - * <strong>Note: No padding is added.</strong> - * @param binaryData - * binary data to encode - * @return String containing Base64 characters + * Encodes binary data using a URL-safe variation of the base64 algorithm but does not chunk the output. The url-safe variation emits - and _ instead of + + * and / characters. <strong>No padding is added.</strong> + * + * @param binaryData binary data to encode. + * @return String containing Base64 characters. * @since 1.4 */ public static String encodeBase64URLSafeString(final byte[] binaryData) { @@ -589,11 +567,9 @@ public class Base64 extends BaseNCodec { /** * Encodes to a byte64-encoded integer according to crypto standards such as W3C's XML-Signature. * - * @param bigInteger - * a BigInteger - * @return A byte array containing base64 character data - * @throws NullPointerException - * if null is passed in + * @param bigInteger a BigInteger. + * @return A byte array containing base64 character data. + * @throws NullPointerException if null is passed in. * @since 1.4 */ public static byte[] encodeInteger(final BigInteger bigInteger) { @@ -602,13 +578,10 @@ public class Base64 extends BaseNCodec { } /** - * Tests a given byte array to see if it contains only valid characters within the Base64 alphabet. Currently the - * method treats whitespace as valid. + * Tests a given byte array to see if it contains only valid characters within the Base64 alphabet. Currently the method treats whitespace as valid. * - * @param arrayOctet - * byte array to test - * @return {@code true} if all bytes are valid characters in the Base64 alphabet or if the byte array is empty; - * {@code false}, otherwise + * @param arrayOctet byte array to test. + * @return {@code true} if all bytes are valid characters in the Base64 alphabet or if the byte array is empty; {@code false}, otherwise. * @deprecated 1.5 Use {@link #isBase64(byte[])}, will be removed in 2.0. */ @Deprecated @@ -619,15 +592,12 @@ public class Base64 extends BaseNCodec { /** * Tests whether or not the {@code octet} is in the base 64 alphabet. * <p> - * Note: this method threats all characters included within standard base64 and base64url encodings - * as valid base64 characters. This includes the '+' and '/' (standard base64), as well as - * '-' and '_' (url safe base64) characters. - * For enforcing verification against strict standard Base64 or Base64 URL Safe tables, - * please use {@link #isBase64Standard} or {@link #isBase64Url} methods respectively. + * This method threats all characters included within standard base64 and base64url encodings as valid base64 characters. This includes the '+' and '/' + * (standard base64), as well as '-' and '_' (URL-safe base64) characters. For enforcing verification against strict standard Base64 or Base64 URL Safe + * tables, please use {@link #isBase64Standard} or {@link #isBase64Url} methods respectively. * </p> * - * @param octet - * The value to test + * @param octet The value to test. * @return {@code true} if the value is defined in the base 64 alphabet, {@code false} otherwise. * @since 1.4 */ @@ -636,20 +606,15 @@ public class Base64 extends BaseNCodec { } /** - * Tests a given byte array to see if it contains only valid characters within the Base64 alphabet. Currently the - * method treats whitespace as valid. + * Tests a given byte array to see if it contains only valid characters within the Base64 alphabet. Currently the method treats whitespace as valid. * <p> - * Note: this method threats all characters included within standard base64 and base64url encodings - * as valid base64 characters. This includes the '+' and '/' (standard base64), as well as - * '-' and '_' (url safe base64) characters. - * For enforcing verification against strict standard Base64 or Base64 URL Safe tables, - * please use {@link #isBase64Standard} or {@link #isBase64Url} methods respectively. + * This method treats all characters included within standard base64 and base64url encodings as valid base64 characters. This includes the '+' and '/' + * (standard base64), as well as '-' and '_' (URL-safe base64) characters. For enforcing verification against strict standard Base64 or Base64 URL Safe + * tables, please use {@link #isBase64Standard} or {@link #isBase64Url} methods respectively. * </p> * - * @param arrayOctet - * byte array to test - * @return {@code true} if all bytes are valid characters in the Base64 alphabet or if the byte array is empty; - * {@code false}, otherwise + * @param arrayOctet byte array to test. + * @return {@code true} if all bytes are valid characters in the Base64 alphabet or if the byte array is empty; {@code false}, otherwise. * @since 1.5 */ public static boolean isBase64(final byte[] arrayOctet) { @@ -662,20 +627,15 @@ public class Base64 extends BaseNCodec { } /** - * Tests a given String to see if it contains only valid characters within the Base64 alphabet. Currently the - * method treats whitespace as valid. + * Tests a given String to see if it contains only valid characters within the Base64 alphabet. Currently the method treats whitespace as valid. * <p> - * Note: this method threats all characters included within standard base64 and base64url encodings - * as valid base64 characters. This includes the '+' and '/' (standard base64), as well as - * '-' and '_' (url safe base64) characters. - * For enforcing verification against strict standard Base64 or Base64 URL Safe tables, - * please use {@link #isBase64Standard} or {@link #isBase64Url} methods respectively. + * This method threats all characters included within standard base64 and base64url encodings as valid base64 characters. This includes the '+' and '/' + * (standard base64), as well as '-' and '_' (URL-safe base64) characters. For enforcing verification against strict standard Base64 or Base64 URL Safe + * tables, please use {@link #isBase64Standard} or {@link #isBase64Url} methods respectively. * </p> * - * @param base64 - * String to test - * @return {@code true} if all characters in the String are valid characters in the Base64 alphabet or if - * the String is empty; {@code false}, otherwise + * @param base64 String to test. + * @return {@code true} if all characters in the String are valid characters in the Base64 alphabet or if the String is empty; {@code false}, otherwise. * @since 1.5 */ public static boolean isBase64(final String base64) { @@ -685,13 +645,12 @@ public class Base64 extends BaseNCodec { /** * Tests whether or not the {@code octet} is in the standard base 64 alphabet. * <p> - * Note: implementation of this method is aligned with the Table 1 of RFC 2045. + * This implementation is aligned with <a href="https://www.ietf.org/rfc/rfc2045#:~:text=Table%201%3A%20The%20Base64%20Alphabet">RFC 2045 Table 1: The + * Base64 Alphabet</a>. * </p> * - * @param octet - * The value to test - * @return {@code true} if the value is defined in the standard base 64 alphabet, - * {@code false} otherwise. + * @param octet The value to test. + * @return {@code true} if the value is defined in the standard base 64 alphabet, {@code false} otherwise. * @since 1.21 */ public static boolean isBase64Standard(final byte octet) { @@ -699,16 +658,14 @@ public class Base64 extends BaseNCodec { } /** - * Tests a given byte array to see if it contains only valid characters within the standard Base64 alphabet. - * The method treats whitespace as valid. + * Tests a given byte array to see if it contains only valid characters within the standard Base64 alphabet. The method treats whitespace as valid. * <p> - * Note: implementation of this method is aligned with the Table 1 of RFC 2045. + * This implementation is aligned with <a href="https://www.ietf.org/rfc/rfc2045#:~:text=Table%201%3A%20The%20Base64%20Alphabet">RFC 2045 Table 1: The + * Base64 Alphabet</a>. * </p> * - * @param arrayOctet - * byte array to test - * @return {@code true} if all bytes are valid characters in the standard Base64 alphabet. - * {@code false}, otherwise + * @param arrayOctet byte array to test. + * @return {@code true} if all bytes are valid characters in the standard Base64 alphabet. {@code false}, otherwise. * @since 1.21 */ public static boolean isBase64Standard(final byte[] arrayOctet) { @@ -721,17 +678,15 @@ public class Base64 extends BaseNCodec { } /** - * Tests a given String to see if it contains only valid characters within the standard Base64 alphabet. - * The method treats whitespace as valid. + * Tests a given String to see if it contains only valid characters within the standard Base64 alphabet. The method treats whitespace as valid. * <p> - * Note: implementation of this method is aligned with the Table 1 of RFC 2045. + * This implementation is aligned with <a href="https://www.ietf.org/rfc/rfc2045#:~:text=Table%201%3A%20The%20Base64%20Alphabet">RFC 2045 Table 1: The + * Base64 Alphabet</a>. * </p> * - * @param base64 - * String to test - * @return {@code true} if all characters in the String are valid characters in the standard Base64 alphabet or - * if the String is empty; - * {@code false}, otherwise + * @param base64 String to test. + * @return {@code true} if all characters in the String are valid characters in the standard Base64 alphabet or if the String is empty; {@code false}, + * otherwise. * @since 1.21 */ public static boolean isBase64Standard(final String base64) { @@ -739,15 +694,15 @@ public class Base64 extends BaseNCodec { } /** - * Tests whether or not the {@code octet} is in the url safe base 64 alphabet. + * Tests whether or not the {@code octet} is in the URL-safe base 64 alphabet. * <p> - * Note: implementation of this method is aligned with the Table 2 of RFC 4648. + * This implementation is aligned with + * <a href="https://datatracker.ietf.org/doc/html/rfc4648#:~:text=Table%202%3A%20The%20%22URL%20and%20Filename%20safe%22%20Base%2064%20Alphabet">RFC 4648 + * Table 2: The "URL and Filename safe" Base 64 Alphabet</a>. * </p> * - * @param octet - * The value to test - * @return {@code true} if the value is defined in the url safe base 64 alphabet, - * {@code false} otherwise. + * @param octet The value to test. + * @return {@code true} if the value is defined in the URL-safe base 64 alphabet, {@code false} otherwise. * @since 1.21 */ public static boolean isBase64Url(final byte octet) { @@ -755,16 +710,15 @@ public class Base64 extends BaseNCodec { } /** - * Tests a given byte array to see if it contains only valid characters within the URL Safe Base64 alphabet. - * The method treats whitespace as valid. + * Tests a given byte array to see if it contains only valid characters within the URL Safe Base64 alphabet. The method treats whitespace as valid. * <p> - * Note: implementation of this method is aligned with the Table 2 of RFC 4648. + * This implementation is aligned with + * <a href="https://datatracker.ietf.org/doc/html/rfc4648#:~:text=Table%202%3A%20The%20%22URL%20and%20Filename%20safe%22%20Base%2064%20Alphabet">RFC 4648 + * Table 2: The "URL and Filename safe" Base 64 Alphabet</a>. * </p> * - * @param arrayOctet - * byte array to test - * @return {@code true} if all bytes are valid characters in the URL Safe Base64 alphabet. - * {@code false}, otherwise + * @param arrayOctet byte array to test. + * @return {@code true} if all bytes are valid characters in the URL Safe Base64 alphabet, {@code false}, otherwise. * @since 1.21 */ public static boolean isBase64Url(final byte[] arrayOctet) { @@ -777,17 +731,16 @@ public class Base64 extends BaseNCodec { } /** - * Tests a given String to see if it contains only valid characters within the URL Safe Base64 alphabet. - * The method treats whitespace as valid. + * Tests a given String to see if it contains only valid characters within the URL Safe Base64 alphabet. The method treats whitespace as valid. * <p> - * Note: implementation of this method is aligned with the Table 2 of RFC 4648. + * This implementation is aligned with + * <a href="https://datatracker.ietf.org/doc/html/rfc4648#:~:text=Table%202%3A%20The%20%22URL%20and%20Filename%20safe%22%20Base%2064%20Alphabet">RFC 4648 + * Table 2: The "URL and Filename safe" Base 64 Alphabet</a>. * </p> * - * @param base64 - * String to test - * @return {@code true} if all characters in the String are valid characters in the URL Safe Base64 alphabet or - * if the String is empty; - * {@code false}, otherwise + * @param base64 String to test. + * @return {@code true} if all characters in the String are valid characters in the URL Safe Base64 alphabet or if the String is empty; {@code false}, + * otherwise. * @since 1.21 */ public static boolean isBase64Url(final String base64) { @@ -797,8 +750,7 @@ public class Base64 extends BaseNCodec { /** * Returns a byte-array representation of a {@code BigInteger} without sign bit. * - * @param bigInt - * {@code BigInteger} to be converted + * @param bigInt {@code BigInteger} to be converted * @return a byte array representation of the BigInteger parameter */ static byte[] toIntegerBytes(final BigInteger bigInt) { @@ -806,14 +758,12 @@ public class Base64 extends BaseNCodec { // round bitlen bitlen = bitlen + 7 >> 3 << 3; final byte[] bigBytes = bigInt.toByteArray(); - if (bigInt.bitLength() % 8 != 0 && bigInt.bitLength() / 8 + 1 == bitlen / 8) { return bigBytes; } // set up params for copying everything but sign bit int startSrc = 0; int len = bigBytes.length; - // if bigInt is exactly byte-aligned, just skip signbit in copy if (bigInt.bitLength() % 8 == 0) { startSrc = 1; @@ -833,16 +783,11 @@ public class Base64 extends BaseNCodec { * Line separator for encoding. Not used when decoding. Only used if lineLength > 0. */ private final byte[] lineSeparator; - /** - * Convenience variable to help us determine when our buffer is going to run out of room and needs resizing. - * {@code encodeSize = 4 + lineSeparator.length;} + * Convenience variable to help us determine when our buffer is going to run out of room and needs resizing. {@code encodeSize = 4 + lineSeparator.length;} */ private final int encodeSize; - private final boolean isUrlSafe; - - private final boolean isStandardEncodeTable; /** @@ -867,9 +812,7 @@ public class Base64 extends BaseNCodec { * When decoding all variants are supported. * </p> * - * @param urlSafe - * if {@code true}, URL-safe encoding is used. In most cases this should be set to - * {@code false}. + * @param urlSafe if {@code true}, URL-safe encoding is used. In most cases this should be set to {@code false}. * @since 1.4 * @deprecated Use {@link #builder()} and {@link Builder}. */ @@ -910,8 +853,7 @@ public class Base64 extends BaseNCodec { /** * Constructs a Base64 codec used for decoding (all modes) and encoding in URL-unsafe mode. * <p> - * When encoding the line length is given in the constructor, the line separator is CRLF, and the encoding table is - * STANDARD_ENCODE_TABLE. + * When encoding the line length is given in the constructor, the line separator is CRLF, and the encoding table is STANDARD_ENCODE_TABLE. * </p> * <p> * Line lengths that aren't multiples of 4 will still essentially end up being multiples of 4 in the encoded data. @@ -920,10 +862,8 @@ public class Base64 extends BaseNCodec { * When decoding all variants are supported. * </p> * - * @param lineLength - * Each line of encoded data will be at most of the given length (rounded down to the nearest multiple of - * 4). If lineLength <= 0, then the output will not be divided into lines (chunks). Ignored when - * decoding. + * @param lineLength Each line of encoded data will be at most of the given length (rounded down to the nearest multiple of 4). If lineLength <= 0, then + * the output will not be divided into lines (chunks). Ignored when decoding. * @since 1.4 * @deprecated Use {@link #builder()} and {@link Builder}. */ @@ -935,8 +875,7 @@ public class Base64 extends BaseNCodec { /** * Constructs a Base64 codec used for decoding (all modes) and encoding in URL-unsafe mode. * <p> - * When encoding the line length and line separator are given in the constructor, and the encoding table is - * STANDARD_ENCODE_TABLE. + * When encoding the line length and line separator are given in the constructor, and the encoding table is STANDARD_ENCODE_TABLE. * </p> * <p> * Line lengths that aren't multiples of 4 will still essentially end up being multiples of 4 in the encoded data. @@ -945,14 +884,10 @@ public class Base64 extends BaseNCodec { * When decoding all variants are supported. * </p> * - * @param lineLength - * Each line of encoded data will be at most of the given length (rounded down to the nearest multiple of - * 4). If lineLength <= 0, then the output will not be divided into lines (chunks). Ignored when - * decoding. - * @param lineSeparator - * Each line of encoded data will end with this sequence of bytes. - * @throws IllegalArgumentException - * Thrown when the provided lineSeparator included some base64 characters. + * @param lineLength Each line of encoded data will be at most of the given length (rounded down to the nearest multiple of 4). If lineLength <= 0, + * then the output will not be divided into lines (chunks). Ignored when decoding. + * @param lineSeparator Each line of encoded data will end with this sequence of bytes. + * @throws IllegalArgumentException Thrown when the provided lineSeparator included some base64 characters. * @since 1.4 * @deprecated Use {@link #builder()} and {@link Builder}. */ @@ -964,8 +899,7 @@ public class Base64 extends BaseNCodec { /** * Constructs a Base64 codec used for decoding (all modes) and encoding in URL-unsafe mode. * <p> - * When encoding the line length and line separator are given in the constructor, and the encoding table is - * STANDARD_ENCODE_TABLE. + * When encoding the line length and line separator are given in the constructor, and the encoding table is STANDARD_ENCODE_TABLE. * </p> * <p> * Line lengths that aren't multiples of 4 will still essentially end up being multiples of 4 in the encoded data. @@ -974,18 +908,12 @@ public class Base64 extends BaseNCodec { * When decoding all variants are supported. * </p> * - * @param lineLength - * Each line of encoded data will be at most of the given length (rounded down to the nearest multiple of - * 4). If lineLength <= 0, then the output will not be divided into lines (chunks). Ignored when - * decoding. - * @param lineSeparator - * Each line of encoded data will end with this sequence of bytes. - * @param urlSafe - * Instead of emitting '+' and '/' we emit '-' and '_' respectively. urlSafe is only applied to encode - * operations. Decoding seamlessly handles both modes. - * <strong>Note: No padding is added when using the URL-safe alphabet.</strong> - * @throws IllegalArgumentException - * Thrown when the {@code lineSeparator} contains Base64 characters. + * @param lineLength Each line of encoded data will be at most of the given length (rounded down to the nearest multiple of 4). If lineLength <= 0, + * then the output will not be divided into lines (chunks). Ignored when decoding. + * @param lineSeparator Each line of encoded data will end with this sequence of bytes. + * @param urlSafe Instead of emitting '+' and '/' we emit '-' and '_' respectively. urlSafe is only applied to encode operations. Decoding seamlessly + * handles both modes. <strong>No padding is added when using the URL-safe alphabet.</strong> + * @throws IllegalArgumentException Thrown when the {@code lineSeparator} contains Base64 characters. * @since 1.4 * @deprecated Use {@link #builder()} and {@link Builder}. */ @@ -998,8 +926,7 @@ public class Base64 extends BaseNCodec { /** * Constructs a Base64 codec used for decoding (all modes) and encoding in URL-unsafe mode. * <p> - * When encoding the line length and line separator are given in the constructor, and the encoding table is - * STANDARD_ENCODE_TABLE. + * When encoding the line length and line separator are given in the constructor, and the encoding table is STANDARD_ENCODE_TABLE. * </p> * <p> * Line lengths that aren't multiples of 4 will still essentially end up being multiples of 4 in the encoded data. @@ -1008,19 +935,13 @@ public class Base64 extends BaseNCodec { * When decoding all variants are supported. * </p> * - * @param lineLength - * Each line of encoded data will be at most of the given length (rounded down to the nearest multiple of - * 4). If lineLength <= 0, then the output will not be divided into lines (chunks). Ignored when - * decoding. - * @param lineSeparator - * Each line of encoded data will end with this sequence of bytes. - * @param urlSafe - * Instead of emitting '+' and '/' we emit '-' and '_' respectively. urlSafe is only applied to encode - * operations. Decoding seamlessly handles both modes. - * <strong>Note: No padding is added when using the URL-safe alphabet.</strong> + * @param lineLength Each line of encoded data will be at most of the given length (rounded down to the nearest multiple of 4). If lineLength <= 0, + * then the output will not be divided into lines (chunks). Ignored when decoding. + * @param lineSeparator Each line of encoded data will end with this sequence of bytes. + * @param urlSafe Instead of emitting '+' and '/' we emit '-' and '_' respectively. urlSafe is only applied to encode operations. Decoding seamlessly + * handles both modes. <strong>No padding is added when using the URL-safe alphabet.</strong> * @param decodingPolicy The decoding policy. - * @throws IllegalArgumentException - * Thrown when the {@code lineSeparator} contains Base64 characters. + * @throws IllegalArgumentException Thrown when the {@code lineSeparator} contains Base64 characters. * @since 1.15 * @deprecated Use {@link #builder()} and {@link Builder}. */ @@ -1032,28 +953,22 @@ public class Base64 extends BaseNCodec { /** * <p> - * 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. + * 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. * </p> * <p> - * Ignores all non-base64 characters. This is how chunked (for example 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. + * Ignores all non-base64 characters. This is how chunked (for example 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. * </p> * <p> * Thanks to "commons" project in ws.apache.org for the bitwise operations, and general approach. * https://svn.apache.org/repos/asf/webservices/commons/trunk/modules/util/ * </p> * - * @param input - * byte[] array of ASCII data to base64 decode. - * @param inPos - * Position to start reading data from. - * @param inAvail - * Amount of bytes available from input for decoding. - * @param context - * the context to be used + * @param input byte[] array of ASCII data to base64 decode. + * @param inPos Position to start reading data from. + * @param inAvail Amount of bytes available from input for decoding. + * @param context the context to be used. */ @Override void decode(final byte[] input, int inPos, final int inAvail, final Context context) { @@ -1118,24 +1033,21 @@ public class Base64 extends BaseNCodec { /** * <p> - * 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, to flush last - * remaining bytes (if not multiple of 3). + * 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, to flush last remaining bytes (if not multiple of 3). + * </p> + * <p> + * <strong>No padding is added when encoding using the URL-safe alphabet.</strong> * </p> - * <p><strong>Note: No padding is added when encoding using the URL-safe alphabet.</strong></p> * <p> * Thanks to "commons" project in ws.apache.org for the bitwise operations, and general approach. * https://svn.apache.org/repos/asf/webservices/commons/trunk/modules/util/ * </p> * - * @param in - * byte[] array of binary data to base64 encode. - * @param inPos - * Position to start reading data from. - * @param inAvail - * Amount of bytes available from input for encoding. - * @param context - * the context to be used + * @param in byte[] array of binary data to base64 encode. + * @param inPos Position to start reading data from. + * @param inAvail Amount of bytes available from input for encoding. + * @param context the context to be used. */ @Override void encode(final byte[] in, int inPos, final int inAvail, final Context context) { @@ -1221,8 +1133,7 @@ public class Base64 extends BaseNCodec { /** * Returns whether or not the {@code octet} is in the Base64 alphabet. * - * @param octet - * The value to test + * @param octet The value to test. * @return {@code true} if the value is defined in the Base64 alphabet {@code false} otherwise. */ @Override @@ -1241,16 +1152,15 @@ public class Base64 extends BaseNCodec { } /** - * Validates whether decoding the final trailing character is possible in the context - * of the set of possible base 64 values. + * Validates whether decoding the final trailing character is possible in the context of the set of possible base 64 values. * <p> - * The character is valid if the lower bits within the provided mask are zero. This - * is used to test the final trailing base-64 digit is zero in the bits that will be discarded. + * The character is valid if the lower bits within the provided mask are zero. This is used to test the final trailing base-64 digit is zero in the bits + * that will be discarded. * </p> * - * @param emptyBitsMask The mask of the lower bits that should be empty - * @param context the context to be used - * @throws IllegalArgumentException if the bits being checked contain any non-zero value + * @param emptyBitsMask The mask of the lower bits that should be empty. + * @param context the context to be used. + * @throws IllegalArgumentException if the bits being checked contain any non-zero value. */ private void validateCharacter(final int emptyBitsMask, final Context context) { if (isStrictDecoding() && (context.ibitWorkArea & emptyBitsMask) != 0) { @@ -1262,10 +1172,9 @@ public class Base64 extends BaseNCodec { } /** - * Validates whether decoding allows an entire final trailing character that cannot be - * used for a complete byte. + * Validates whether decoding allows an entire final trailing character that cannot be used for a complete byte. * - * @throws IllegalArgumentException if strict decoding is enabled + * @throws IllegalArgumentException if strict decoding is enabled. */ private void validateTrailingCharacter() { if (isStrictDecoding()) {
