MCPcopy Create free account
hub / github.com/SoarGroup/Soar / encode

Method encode

Java/SMLJava/src/main/java/edu/umich/soar/config/Base64.java:31–66  ·  view source on GitHub ↗
(byte in[])

Source from the content-addressed store, hash-verified

29 }
30
31 public static String[] encode(byte in[])
32 {
33 StringBuilder sb = new StringBuilder();
34 List<String> lines = new ArrayList<String>();
35
36 for (int idx = 0; idx < in.length; idx += 3)
37 {
38 int v0 = in[idx] & 0xff;
39 int v1 = idx + 1 < in.length ? in[idx + 1] & 0xff : 0;
40 int v2 = idx + 2 < in.length ? in[idx + 2] & 0xff : 0;
41 int v = (v0 << 16) | (v1 << 8) | v2;
42
43 int a = (v >> 18) & 63;
44 int b = (v >> 12) & 63;
45 int c = (v >> 6) & 63;
46 int d = v & 63;
47
48 sb.append(encodeLut[a]);
49 sb.append(encodeLut[b]);
50 sb.append(encodeLut[c]);
51 sb.append(encodeLut[d]);
52
53 if (idx + 3 >= in.length || sb.length() == 72)
54 {
55 if (idx + 2 >= in.length)
56 sb.setCharAt(sb.length() - 1, '=');
57 if (idx + 1 >= in.length)
58 sb.setCharAt(sb.length() - 2, '=');
59
60 lines.add(sb.toString());
61 sb = new StringBuilder();
62 }
63 }
64
65 return lines.toArray(new String[lines.size()]);
66 }
67
68 public static byte[] decode(String lines[])
69 {

Callers 4

mainMethod · 0.95
setBytesMethod · 0.95
normalize_envFunction · 0.80
add_envFunction · 0.80

Calls 6

lengthMethod · 0.80
toArrayMethod · 0.80
appendMethod · 0.45
addMethod · 0.45
toStringMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected