1. Java.perform(function () {
    2. console.log("--------------start hooking--------------");
    3. function showStack() {
    4. var log = Java.use("android.util.Log");
    5. var Throwable = Java.use("java.lang.Throwable");
    6. console.log(log.getStackTraceString(Throwable.$new()))
    7. }
    8. var base64 = Java.use("android.util.Base64");
    9. base64.encodeToString.overload('[B', 'int').implementation = function (a, b) {
    10. showStack();
    11. console.log("base64.encodeToString: ", JSON.stringify(a));
    12. var result = this.encodeToString(a, b);
    13. console.log("base64.encodeToString result: ", result)
    14. return result;
    15. }
    16. var base64 = Java.use("android.util.Base64");
    17. base64.encodeToString.overload('[B', 'int', 'int', 'int').implementation = function (a, b,c,d) {
    18. showStack();
    19. console.log("base64.encodeToString: ", JSON.stringify(a));
    20. var result = this.encodeToString(a, b,c,d);
    21. console.log("base64.encodeToString result: ", result)
    22. return result;
    23. }
    24. })

    除此之外,还有另几个base64实现方法:
    java.net.URLEncoder
    java.util.Base64
    okio.Base64
    okio.ByteString