// Ripped from https://github.com/Ch0pin/medusa/ and modified to fit Androguard packets

colorLog('[+] LOADING ENCODING/BASE64.JS', {c: Color.Red});

var base64 = Java.use('android.util.Base64');

base64.decode.overloads[0].implementation = function(endString, flags) {
    var ret = this.decode(endString, flags);
    agPacket({endString: endString, flags: flags, ret: ret}).send();
    return ret;
}

base64.encode.overloads[0].implementation = function(byteString, flags) {
    var ret = this.encode(byteString,flags);
    agPacket({byteString: byteString, flags: flags, ret: ret}).send();
    return ret;
}

base64.encode.overloads[1].implementation = function(byteString, offset, ln, flags) {
    var ret = this.encode(byteString, offset, ln, flags);
    agPacket({byteString: byteString, flags: flags, ln: ln, ret: ret}).send();
    return ret;
}

base64.encodeToString.overloads[1].implementation = function(byteString,flags){
    var ret = this.encodeToString(byteString, flags);
    agPacket({byteString: byteString, flags: flags, ret: ret}).send();
    return ret;
}