快叫我java小菜鸟 2019-11-25 10:13 采纳率: 100%
浏览 4807

apache Base64源码最后validateCharacter方法为什么会&上补0的个数?

/**
     * <p>
     * Validates whether the character is possible in the context of the set of possible base 64 values.
     * </p>
     *
     * @param numBits number of least significant bits to check
     * @param context the context to be used
     *
     * @throws IllegalArgumentException if the bits being checked contain any non-zero value
     */
    private long validateCharacter(final int numBitsToDrop, final Context context) {
        i**f ((context.ibitWorkArea & numBitsToDrop) != 0)** {
        throw new IllegalArgumentException(
            "Last encoded character (before the paddings if any) is a valid base 64 alphabet but not a possible value");
        }
        return context.ibitWorkArea >> numBitsToDrop;
    }

我很疑惑的地方是:验证结尾两个或四个比特为0,不应该是&3 或者 &15吗?详细的代码不再贴了,有能解惑的大神先行拜谢了。

问题解决参见:问题解决结果

  • 写回答

1条回答 默认 最新

  • threenewbee 2019-11-25 12:40
    关注

    numBitsToDrop
    顾名思义,这个参数的意思是需要丢弃的位数

    评论

报告相同问题?

悬赏问题

  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?