http://blog.naver.com/PostView.nhn?blogId=linears_&logNo=221131470004&categoryNo=18&parentCategoryNo=0&viewDate=&currentPage=1&postListTopCurrentPage=1&from=postView&userTopListOpen=true&userTopListCount=5&userTopListManageOpen=false&userTopListCurrentPage=1#



http://blog.naver.com/PostView.nhn?blogId=linears_&logNo=221104158049&categoryNo=18&parentCategoryNo=0&viewDate=&currentPage=1&postListTopCurrentPage=1&from=postView&userTopListOpen=true&userTopListCount=5&userTopListManageOpen=false&userTopListCurrentPage=1


http://blog.naver.com/PostView.nhn?blogId=linears_&logNo=221080008256&categoryNo=18&parentCategoryNo=0&viewDate=&currentPage=1&postListTopCurrentPage=1&from=postView&userTopListOpen=true&userTopListCount=5&userTopListManageOpen=false&userTopListCurrentPage=1

public static boolean isCompressed(final byte[] compressed) {
        return (compressed[0== (byte) (GZIPInputStream.GZIP_MAGIC)) && (compressed[1== (byte) (GZIPInputStream.GZIP_MAGIC >> 8));
    }
    
    public static byte[] compress(final String str) throws IOException {
        if ((str == null|| (str.length() == 0)) {
            return null;
        }
        ByteArrayOutputStream obj = new ByteArrayOutputStream();
        GZIPOutputStream gzip = new GZIPOutputStream(obj);
        gzip.write(str.getBytes("UTF-8"));
        gzip.close();
        //System.out.println(obj.toByteArray()[1]);
        return obj.toByteArray();
    }
    
    public static String packetDecompress(final String msg){
        //byte[] bcdz = compress("asdasdz");
        //System.out.println(decompress(bcdz));
        //System.out.println(bcdz[0]);
        
        //String ad = "{\"type\":\"Buffer\",\"data\":[31,139,8,0,0,0,0,0,0,0,99,9,73,18,16,22,101,9,73,150,20,148,100,9,73,18,73,73,66,99,139,37,139,130,216,146,169,44,68,171,140,70,85,74,138,162,81,27,6,129,13,20,184,108,184,42,194,46,1,0,199,90,197,78,61,3,0,0]}";
        //ad = "[31,-117,8,0,0,0,0,0,0,0,75,44,78,73,44,78,-87,2,0,35,70,-59,53,7,0,0,0,0,0,0,0,0]";
        //ad = "[31,139,8,0,0,0,0,0,0,0,99,9,73,18,16,22,101,9,73,18,145,76,141,102,129,114,146,37,5,37,1,247,124,130,131,25,0,0,0]";
        String[] tmp;
        int lastPos = 0, pos = 0;   
        pos = msg.indexOf("[");
        lastPos = msg.indexOf("]");
        String msg2 = msg.substring(pos+1, lastPos);
        //System.out.println(ad);
        tmp = msg2.split(",");
        byte[] bytes = new byte[tmp.length];
        for(int i=0;i<tmp.length;i++){
            if(Integer.valueOf(tmp[i]) > 127) bytes[i] = (byte) (Integer.valueOf(tmp[i])+256); // -128 ~ 127 자바 byte 타입 범위
            else bytes[i] = Byte.valueOf(tmp[i]);
        }
        try {
            return XorDecryption(decompress(bytes));
        } catch (IOException e) {
            e.printStackTrace();
        }
        return "NULL";
        /*System.out.println(decompress(bytes));
        System.out.println(XorDecryption(decompress(bytes)));
        System.out.println(tmp.length);*/
    }
 
    public static String decompress(final byte[] compressed) throws IOException {
        String outStr = "";
        if ((compressed == null|| (compressed.length == 0)) {
            return "";
        }
        if (isCompressed(compressed)) {
            GZIPInputStream gis = new GZIPInputStream(new ByteArrayInputStream(compressed));
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(gis, "UTF-8"));
 
            String line;
            while ((line = bufferedReader.readLine()) != null) {
                outStr += line;
            }
        } else {
            //outStr = new String(compressed);
            outStr = "HACKING";
        }
        return outStr;
    }
    


'Java' 카테고리의 다른 글

java 참고  (0) 2019.01.17
웹페이지를 PDF로 변환하는 라이브러리 +pdf 관련 자바 라이브러리  (0) 2017.09.27
자바 참고학습  (0) 2017.07.20
자바강의  (0) 2017.01.03

http://dev-j.tistory.com/15 참고

'Java' 카테고리의 다른 글

java 참고  (0) 2019.01.17
[Java] 문자열 압축 소스 Java / Programming  (0) 2019.01.17
자바 참고학습  (0) 2017.07.20
자바강의  (0) 2017.01.03

http://hunit.tistory.com/ 



https://opentutorials.org/module/516

+ Recent posts