|
|
Java-Quelltext |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
package eu.knuddelz.net.Security; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.util.zip.DataFormatException; import java.util.zip.Deflater; import java.util.zip.Inflater; public class Compressor { public static byte[] decompress(byte[] compressed) { Inflater decompressor = new Inflater(); decompressor.setInput(compressed); ByteArrayOutputStream bos = new ByteArrayOutputStream(compressed.length); // Decompress the data byte[] buf = new byte[1024]; while (!decompressor.finished()) { try { int count = decompressor.inflate(buf); bos.write(buf, 0, count); } catch (DataFormatException e) { } } try { bos.close(); } catch (IOException e) { } byte[] decompressedData = bos.toByteArray(); return decompressedData; } public static byte[] compress(String message) throws UnsupportedEncodingException { return compress(message.getBytes()); } public static byte[] compress(byte[] bytes) throws UnsupportedEncodingException { Deflater compressor = new Deflater(Deflater.HUFFMAN_ONLY); compressor.setInput(bytes); compressor.finish(); ByteArrayOutputStream bos = new ByteArrayOutputStream(bytes.length); byte[] buf = new byte[1024]; while (!compressor.finished()) { int count = compressor.deflate(buf); bos.write(buf, 0, count); } try { bos.close(); } catch (IOException e) { } byte[] compressedData = bos.toByteArray(); return compressedData; } } |
Naja nachweisen ist schwer, stimmt schon. Aber warum da was riskieren, wenn es auch ohne geht. Hast du eigentlich eine Statistik wieviel Knuddels da an Traffic spart durch ihren Huffman Tree... Ich komme über den Java-Deflater auf ca. 15% .Auch dann darf man Huffman benutzen, nach dem Dekompilieren stimmt der Code nicht mehr 100% (wegen des Obfuskierens wahrscheinlich nicht mal mehr 50%) mit dem von Knuddels überein und da können die dir nichts nachweisen. Wenn man ganz sicher gehen will sonst einfach einen anderen Tree benutzen.