• android中的Bas64为何缺少 ==


    android中的Bas64为何缺少 ==

    前言

    在逆向xxxx哩App,寻找did参数生成方法时,发现如下代码生成的Base64编码与python模拟生成的结果差别在最后的两个==

    java丢失了==python中有==

    这里第二个参数传入的是11,不知道什么意思~
    在这里插入图片描述

    分析

    生成代码如下:

    Base64.encode(bytes, 11)
    
    • 1

    且其第二个参数flags传入的是11,然后查看导入的是哪个包的Base64,去找源代码看看

    查看发现导入的是这个包中的Base64

    import android.util.Base64;
    
    • 1

    其源码如下图所示
    在这里插入图片描述
    标志位说明:

    flags说明注释flag
    DEFAULTDefault values for encoder/decoder flags.默认模式0
    NO_PADDINGEncoder flag bit to omit the padding ‘=’ characters at the end of the output (if any).省略末尾填充的’='字符1
    NO_WRAPEncoder flag bit to omit all line terminators (i.e., the output will be on one long line).省略所有的终止符2
    CRLFEncoder flag bit to indicate lines should be terminated with a CRLF pair instead of just an LF.指示行的编码器标志位用CRLF替代LF4
    URL_SAFEEncoder/decoder flag bit to indicate using the “URL and filename safe” variant of Base64 (see RFC 3548 section 4) where - and _ are used in place of + and /.URL和文件名安全方式,替换其中不符合url安全的字符如+和/8
    NO_CLOSEFlag to pass to Base64OutputStream to indicate that it should not close the output stream it is wrapping when it itself is closed.传递给Base64OutputStream标记以指示它本身关闭时不应关闭它正在包装的输出流16

    所以

    return new String(Base64.encode(bytes, 11));
    
    • 1

    中的,11=1+2+8,即:NO_PADDINGNO_WRAPURL_SAFE

  • 相关阅读:
    jmeter请求接口问题小记
    Python基础之面向对象:3、继承与派生
    记第一次与世界的交流
    服务器的区别跟服务器被攻击了怎么解决
    详解Docker的网络模式之host模式(host网络模式)
    Qt的ui文件不能简单复制
    基于python的在线文档管理系统vue
    【2024中高级向】22道前端面试题附答案
    【C语言】递归详解汉诺塔问题
    Django之初入门
  • 原文地址:https://blog.csdn.net/dzdzdzd12347/article/details/127772830