X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=core%2Fsrc%2Fnet%2Fsf%2Fopenrocket%2Futil%2FBase64.java;fp=core%2Fsrc%2Fnet%2Fsf%2Fopenrocket%2Futil%2FBase64.java;h=aeed54a1dd0f30c5bef6c6d3dace98651aedeb31;hb=9349577cdfdff682b2aabd6daa24fdc3a7449b58;hp=042d36715d41840522a586db27f4011055a18873;hpb=30ba0a882f0c061176ba14dbf86d3d6fad096c02;p=debian%2Fopenrocket diff --git a/core/src/net/sf/openrocket/util/Base64.java b/core/src/net/sf/openrocket/util/Base64.java index 042d3671..aeed54a1 100644 --- a/core/src/net/sf/openrocket/util/Base64.java +++ b/core/src/net/sf/openrocket/util/Base64.java @@ -3,7 +3,6 @@ package net.sf.openrocket.util; import java.util.Arrays; import java.util.HashMap; import java.util.Map; -import java.util.Random; public class Base64 { @@ -81,7 +80,7 @@ public class Base64 { if (p==0) break; if (p!=4) { - throw new IllegalArgumentException("Data ended when decoding Base64, p="+p); + throw new IllegalArgumentException("Data ended when decoding Base64, data=" + data + ", p="+p); } int l = decodeGroup(block, array, length); @@ -166,67 +165,4 @@ public class Base64 { return 3; } - - - public static void main(String[] arg) { - Random rnd = new Random(); - - for (int round=0; round < 1000; round++) { - int n = rnd.nextInt(1000); - n = 100000; - - byte[] array = new byte[n]; - rnd.nextBytes(array); - - String encoded = encode(array); - - System.out.println(encoded); - System.exit(0); -// for (int i=0; i<1000; i++) { -// int pos = rnd.nextInt(encoded.length()); -// String s1 = encoded.substring(0, pos); -// String s2 = encoded.substring(pos); -// switch (rnd.nextInt(15)) { -// case 0: -// encoded = s1 + " " + s2; -// break; -// case 1: -// encoded = s1 + "\u0009" + s2; -// break; -// case 2: -// encoded = s1 + "\n" + s2; -// break; -// case 3: -// encoded = s1 + "\u000B" + s2; -// break; -// case 4: -// encoded = s1 + "\r" + s2; -// break; -// case 5: -// encoded = s1 + "\u000C" + s2; -// break; -// case 6: -// encoded = s1 + "\u001C" + s2; -// break; -// } -// } - - byte[] decoded = null; - try { - decoded = decode(encoded); - } catch (IllegalArgumentException e) { - e.printStackTrace(); - System.err.println("Bad data:\n"+encoded); - System.exit(1); - } - - if (!Arrays.equals(array, decoded)) { - System.err.println("Data differs! n="+n); - System.exit(1); - } - System.out.println("n="+n+" ok!"); - } - } - - }