• proguard混淆jar文件


    Proguard是个优秀的java混淆工具,使用示例如下,一个java工程对外接口代码如下(无需混淆)

    package com.ciaos.open;
    
    import com.ciaos.inner.InnerTool;
    
    public class OpenTool {
        public static void method()
        {
            System.out.println("public method");
            InnerTool.method();
        }
    }

    内部调用函数如下(需要混淆)

    package com.ciaos.inner;
    
    public class InnerTool {
        public static void method()
        {
            System.out.println("need encrypt");
        }
    }

    我们只想在打包的jar文件中保留OpenTool.method接口,则proguard配置文件library.pro文件如下:

    #
    # This ProGuard configuration file illustrates how to process a program
    # library, such that it remains usable as a library.
    # Usage:
    #     java -jar proguard.jar @library.pro
    #
    
    # Specify the input jars, output jars, and library jars.
    # In this case, the input jar is the program library that we want to process.
    
    -injars  D:libtool.jar
    -outjars D:libtool_min.jar
    
    -libraryjars  C:UsersshipengAppDataLocalMyEclipse Professional 2014inarycom.sun.java.jdk7.win32.x86_1.7.0.u45jrelib
    t.jar
    #-libraryjars  E:Worksfastjson-1.1.34.android.jar
    
    
    -printmapping mapproguard.map 
    -overloadaggressively 
    -defaultpackage ''  
    -allowaccessmodification 
    -dontoptimize
    -overloadaggressively
    -keepattributes InnerClasses,SourceFile,LineNumberTable,Signature
    -optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
    -optimizationpasses 5
    -keepattributes Exceptions
    -keep public class com.ciaos.open.OpenTool
    {   
    public *; 
    }
    #-keep public class com.ciaos.inner.InnerTool 
    #{   
    #public *; 
    #}

    混淆工具脚本

    del "D:libtool_min.jar"
    java -jar lib/proguard.jar @library.pro
    pause

    更多用法参照Proguard官网,proguard也有插件集成到eclipse中。

  • 相关阅读:
    [转载]setup factory使用方法
    MFC中调用WPF教程
    Reduce the Number of SQL Statements
    Library Cache Hit Ratio
    Seconds in wait
    PX Deq: Execute Reply等待事件
    RoundTrip Time
    Changing an Init.ora Parameter
    PX qref latch等待事件
    提高DBWR进程的吞吐量
  • 原文地址:https://www.cnblogs.com/ciaos/p/4368588.html
Copyright © 2020-2023  润新知