@@ -33,31 +33,31 @@ public class Base64 {
33
33
/**
34
34
* Encoder flag bit to omit the padding '=' characters at the end of the output (if any).
35
35
*/
36
- public static final int NO_PADDING = 1 ;
36
+ private static final int NO_PADDING = 1 ;
37
37
38
38
/**
39
39
* Encoder flag bit to omit all line terminators (i.e., the output will be on one long line).
40
40
*/
41
- public static final int NO_WRAP = 2 ;
41
+ private static final int NO_WRAP = 2 ;
42
42
43
43
/**
44
44
* Encoder flag bit to indicate lines should be terminated with a CRLF pair instead of just an
45
45
* LF. Has no effect if {@code NO_WRAP} is specified as well.
46
46
*/
47
- public static final int CRLF = 4 ;
47
+ private static final int CRLF = 4 ;
48
48
49
49
/**
50
50
* Encoder/decoder flag bit to indicate using the "URL and filename safe" variant of Base64 (see
51
51
* RFC 3548 section 4) where {@code -} and {@code _} are used in place of {@code +} and {@code
52
52
* /}.
53
53
*/
54
- public static final int URL_SAFE = 8 ;
54
+ private static final int URL_SAFE = 8 ;
55
55
56
56
/**
57
57
* Flag to pass to {@link Base64OutputStream} to indicate that it should not close the output
58
58
* stream it is wrapping when it itself is closed.
59
59
*/
60
- public static final int NO_CLOSE = 16 ;
60
+ static final int NO_CLOSE = 16 ;
61
61
62
62
// --------------------------------------------------------
63
63
// shared code
@@ -80,7 +80,7 @@ private Base64() {
80
80
* @param flags controls certain features of the decoded output. Pass {@code DEFAULT} to decode
81
81
* standard Base64.
82
82
* @return decoded bytes
83
- * @throws IllegalArgumentException if the input contains incorrect padding
83
+ * @throws java.lang. IllegalArgumentException if the input contains incorrect padding
84
84
*/
85
85
public static byte [] decode (String str , int flags ) {
86
86
return decode (str .getBytes (), flags );
@@ -95,31 +95,30 @@ public static byte[] decode(String str, int flags) {
95
95
* @param flags controls certain features of the decoded output. Pass {@code DEFAULT} to decode
96
96
* standard Base64.
97
97
* @return decoded bytes
98
- * @throws IllegalArgumentException if the input contains incorrect padding
98
+ * @throws java.lang. IllegalArgumentException if the input contains incorrect padding
99
99
*/
100
- public static byte [] decode (byte [] input , int flags ) {
101
- return decode (input , 0 , input .length , flags );
100
+ private static byte [] decode (byte [] input , int flags ) {
101
+ return decode (input , input .length , flags );
102
102
}
103
103
104
104
/**
105
105
* Decode the Base64-encoded data in input and return the data in a new byte array.
106
106
* <p> </p> <p>The padding '=' characters at the end are considered optional, but if any
107
107
* are present, there must be the correct number of them.
108
108
*
109
- * @param input the data to decode
110
- * @param offset the position within the input array at which to start
111
- * @param len the number of bytes of input to decode
112
- * @param flags controls certain features of the decoded output. Pass {@code DEFAULT} to decode
113
- * standard Base64.
109
+ * @param input the data to decode
110
+ * @param len the number of bytes of input to decode
111
+ * @param flags controls certain features of the decoded output. Pass {@code DEFAULT} to decode
112
+ * standard Base64.
114
113
* @return decoded bytes for given offset and length
115
- * @throws IllegalArgumentException if the input contains incorrect padding
114
+ * @throws java.lang. IllegalArgumentException if the input contains incorrect padding
116
115
*/
117
- public static byte [] decode (byte [] input , int offset , int len , int flags ) {
116
+ private static byte [] decode (byte [] input , int len , int flags ) {
118
117
// Allocate space for the most data the input could represent.
119
118
// (It could contain less if it contains whitespace, etc.)
120
119
Decoder decoder = new Decoder (flags , new byte [len * 3 / 4 ]);
121
120
122
- if (!decoder .process (input , offset , len , true )) {
121
+ if (!decoder .process (input , 0 , len , true )) {
123
122
throw new IllegalArgumentException ("bad base-64" );
124
123
}
125
124
@@ -183,7 +182,7 @@ public static String encodeToString(byte[] input, int offset, int len, int flags
183
182
* in output that adheres to RFC 2045.
184
183
* @return base64 encoded input as bytes
185
184
*/
186
- public static byte [] encode (byte [] input , int flags ) {
185
+ private static byte [] encode (byte [] input , int flags ) {
187
186
return encode (input , 0 , input .length , flags );
188
187
}
189
188
@@ -197,7 +196,7 @@ public static byte[] encode(byte[] input, int flags) {
197
196
* results in output that adheres to RFC 2045.
198
197
* @return base64 encoded input as bytes
199
198
*/
200
- public static byte [] encode (byte [] input , int offset , int len , int flags ) {
199
+ private static byte [] encode (byte [] input , int offset , int len , int flags ) {
201
200
Encoder encoder = new Encoder (flags , null );
202
201
203
202
// Compute the exact length of the array we will produce.
@@ -238,8 +237,8 @@ public static byte[] encode(byte[] input, int offset, int len, int flags) {
238
237
}
239
238
240
239
/* package */ static abstract class Coder {
241
- public byte [] output ;
242
- public int op ;
240
+ byte [] output ;
241
+ int op ;
243
242
244
243
/**
245
244
* Encode/decode another block of input data. this.output is provided by the caller, and
@@ -264,7 +263,7 @@ public static byte[] encode(byte[] input, int offset, int len, int flags) {
264
263
/**
265
264
* Lookup table for turning bytes into their position in the Base64 alphabet.
266
265
*/
267
- private static final int DECODE [] = {
266
+ private static final int [] DECODE = {
268
267
-1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 ,
269
268
-1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 ,
270
269
-1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , 62 , -1 , -1 , -1 , 63 ,
@@ -287,7 +286,7 @@ public static byte[] encode(byte[] input, int offset, int len, int flags) {
287
286
* Decode lookup table for the "web safe" variant (RFC 3548 sec. 4) where - and _ replace +
288
287
* and /.
289
288
*/
290
- private static final int DECODE_WEBSAFE [] = {
289
+ private static final int [] DECODE_WEBSAFE = {
291
290
-1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 ,
292
291
-1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 ,
293
292
-1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 , 62 , -1 , -1 ,
@@ -321,7 +320,7 @@ public static byte[] encode(byte[] input, int offset, int len, int flags) {
321
320
private int state ; // state number (0 to 6)
322
321
private int value ;
323
322
324
- public Decoder (int flags , byte [] output ) {
323
+ Decoder (int flags , byte [] output ) {
325
324
this .output = output ;
326
325
327
326
alphabet = ((flags & URL_SAFE ) == 0 ) ? DECODE : DECODE_WEBSAFE ;
@@ -526,12 +525,12 @@ public boolean process(byte[] input, int offset, int len, boolean finish) {
526
525
* (the maximum allowable according to <a href="https://www.ietf.org/rfc/rfc2045.txt">RFC
527
526
* 2045</a>).
528
527
*/
529
- public static final int LINE_GROUPS = 19 ;
528
+ static final int LINE_GROUPS = 19 ;
530
529
531
530
/**
532
531
* Lookup table for turning Base64 alphabet positions (6 bits) into output bytes.
533
532
*/
534
- private static final byte ENCODE [] = {
533
+ private static final byte [] ENCODE = {
535
534
'A' , 'B' , 'C' , 'D' , 'E' , 'F' , 'G' , 'H' , 'I' , 'J' , 'K' , 'L' , 'M' , 'N' , 'O' , 'P' ,
536
535
'Q' , 'R' , 'S' , 'T' , 'U' , 'V' , 'W' , 'X' , 'Y' , 'Z' , 'a' , 'b' , 'c' , 'd' , 'e' , 'f' ,
537
536
'g' , 'h' , 'i' , 'j' , 'k' , 'l' , 'm' , 'n' , 'o' , 'p' , 'q' , 'r' , 's' , 't' , 'u' , 'v' ,
@@ -541,21 +540,21 @@ public boolean process(byte[] input, int offset, int len, boolean finish) {
541
540
/**
542
541
* Lookup table for turning Base64 alphabet positions (6 bits) into output bytes.
543
542
*/
544
- private static final byte ENCODE_WEBSAFE [] = {
543
+ private static final byte [] ENCODE_WEBSAFE = {
545
544
'A' , 'B' , 'C' , 'D' , 'E' , 'F' , 'G' , 'H' , 'I' , 'J' , 'K' , 'L' , 'M' , 'N' , 'O' , 'P' ,
546
545
'Q' , 'R' , 'S' , 'T' , 'U' , 'V' , 'W' , 'X' , 'Y' , 'Z' , 'a' , 'b' , 'c' , 'd' , 'e' , 'f' ,
547
546
'g' , 'h' , 'i' , 'j' , 'k' , 'l' , 'm' , 'n' , 'o' , 'p' , 'q' , 'r' , 's' , 't' , 'u' , 'v' ,
548
547
'w' , 'x' , 'y' , 'z' , '0' , '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' , '-' , '_' ,
549
548
};
550
- final public boolean do_padding ;
551
- final public boolean do_newline ;
552
- final public boolean do_cr ;
549
+ final boolean do_padding ;
550
+ final boolean do_newline ;
551
+ final boolean do_cr ;
553
552
final private byte [] tail ;
554
553
final private byte [] alphabet ;
555
554
/* package */ int tailLen ;
556
555
private int count ;
557
556
558
- public Encoder (int flags , byte [] output ) {
557
+ Encoder (int flags , byte [] output ) {
559
558
this .output = output ;
560
559
561
560
do_padding = (flags & NO_PADDING ) == 0 ;
0 commit comments