allatori8.0文档翻译-第十五步:定制加密字符串

第十五步:定制加密字符串

在第一步的基础上修改,定制加密字符串。

custom.jar 包含一个带有加密解密样例方法的类。

配置文件如下:

<config>
    <input>
        <jar in="test.jar" out="obf-test.jar"/>
        <jar in="mousegestures-1.2.jar" out="obf-mousegestures-1.2.jar"/>

        <jar in="custom.jar" out="obf-custom.jar"/>
    </input>

    <-names>
        <class access="protected+">
            <field access="protected+"/>
            <method access="protected+"/>
        </class>
    </keep-names>

    <!-- We recommend using the v3 setting if custom string encryption is applied to ALL your classes. -->
    <!-- This way Allatori would not add any additional (unused) string decryption methods. -->
    <!-- If you combine custom string encryption and Allatori string encryption, then the default v4 setting is recommended. -->
    <property name="string-encryption-version" value="v3"/>

    <!-- Disabling string encryption in custom decryption methods, as it could lead to infinite recursive calls. -->
    <property name="string-encryption" value="disable" apply2class="class com.allatori.custom.EncryptDecryptString" apply2method="decrypt*(java.lang.String)"/>

    <property name="string-encryption" value="maximum"/>
    <property name="string-encryption-type" value="custom(com.allatori.custom.EncryptDecryptString.encryptString, com.allatori.custom.EncryptDecryptString.decryptString)"/>

    <property name="log-file" value="log.xml"/>
</config>

其中

<jar in="custom.jar" out="obf-custom.jar"/>
......
<property name="string-encryption-version" value="v3"/>
......
<property name="string-encryption" value="disable" apply2class="class com.allatori.custom.EncryptDecryptString" apply2method="decrypt*(java.lang.String)"/>

<property name="string-encryption" value="maximum"/>
<property name="string-encryption-type" value="custom(com.allatori.custom.EncryptDecryptString.encryptString, com.allatori.custom.EncryptDecryptString.decryptString)"/>
......

是改变的部分。

你可以在指定的包中应用定制化的字符串加密方法:

<property name="string-encryption-type" value="custom(package.EncryptClassName.encryptMethodName, package.DecryptClassName.decryptMethodName)" apply2class="class com.some.package.*"/>

也可以使用多种字符串加密方法:

<property name="string-encryption-type" value="custom(package.EncryptClassName1.encryptMethodName1, package.DecryptClassName1.decryptMethodName1)" apply2class="class com.some.package.*"/>
<property name="string-encryption-type" value="custom(package.EncryptClassName2.encryptMethodName2, package.DecryptClassName2.decryptMethodName2)" apply2class="class com.some.other.package.*"/>
    <!-- Methods for classes not matched by the rules above -->
<property name="string-encryption-type" value="custom(package.EncryptClassName3.encryptMethodName3, package.DecryptClassName3.decryptMethodName3)"/>

加密方法只在混淆过程中需要,运行过程中不需要。

解密方法在运行时是需要的,你可以把它们放到你程序的任何地方。

定制化加密方法可以使用国际化信息。在Allatori的methodCall方法中,你可以在加密方法中跟踪并翻译字符,也可以在运行时的解密方法中对字符串进行国际化处理。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值