MCPcopy Create free account
hub / github.com/directwebremoting/dwr / Base64

Class Base64

core/api/main/java/org/directwebremoting/util/Base64.java:78–493  ·  view source on GitHub ↗

This class provides encode/decode for RFC 2045 Base64 as defined by RFC 2045, N. Freed and N. Borenstein. RFC 2045 : Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies. Reference 1996 @author Jeffrey Rodriguez @

Source from the content-addressed store, hash-verified

76 *
77 */
78@SuppressWarnings({"ALL"})
79public class Base64 {
80
81 // Create constants pertaining to the chunk requirement
82 static final int CHUNK_SIZE = 76;
83 static final byte[] CHUNK_SEPARATOR = "\n".getBytes();
84
85 // Create numerical and byte constants
86 static final int BASELENGTH = 255;
87 static final int LOOKUPLENGTH = 64;
88 static final int TWENTYFOURBITGROUP = 24;
89 static final int EIGHTBIT = 8;
90 static final int SIXTEENBIT = 16;
91 static final int SIXBIT = 6;
92 static final int FOURBYTE = 4;
93 static final int SIGN = -128;
94 static final byte PAD = (byte) '=';
95
96 // Create arrays to hold the base64 characters and a
97 // lookup for base64 chars
98 private static byte[] base64Alphabet = new byte[BASELENGTH];
99 private static byte[] lookUpBase64Alphabet = new byte[LOOKUPLENGTH];
100
101 // Populating the lookup and character arrays
102 static {
103 for (int i = 0; i < BASELENGTH; i++) {
104 base64Alphabet[i] = (byte) -1;
105 }
106 for (int i = 'Z'; i >= 'A'; i--) {
107 base64Alphabet[i] = (byte) (i - 'A');
108 }
109 for (int i = 'z'; i >= 'a'; i--) {
110 base64Alphabet[i] = (byte) (i - 'a' + 26);
111 }
112 for (int i = '9'; i >= '0'; i--) {
113 base64Alphabet[i] = (byte) (i - '0' + 52);
114 }
115
116 base64Alphabet['+'] = 62;
117 base64Alphabet['/'] = 63;
118
119 for (int i = 0; i <= 25; i++) {
120 lookUpBase64Alphabet[i] = (byte) ('A' + i);
121 }
122
123 for (int i = 26, j = 0; i <= 51; i++, j++) {
124 lookUpBase64Alphabet[i] = (byte) ('a' + j);
125 }
126
127 for (int i = 52, j = 0; i <= 61; i++, j++) {
128 lookUpBase64Alphabet[i] = (byte) ('0' + j);
129 }
130
131 lookUpBase64Alphabet[62] = (byte) '+';
132 lookUpBase64Alphabet[63] = (byte) '/';
133 }
134
135 private static boolean isBase64(byte octect) {

Callers

nothing calls this directly

Calls 1

getBytesMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…