V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
masonnpe
V2EX  ›  Java

有人遇到过 InputStream 转 byte[]再转回 InputStream 导致 3des 解密报错的情况么=。=

  •  
  •   masonnpe · Mar 13, 2019 · 2302 views
    This topic created in 2602 days ago, the information mentioned may be changed or developed.

    会报 javax.crypto.IllegalBlockSizeException: Input length must be multiple of 8 when decrypting with padded cipher

    2 replies    2019-03-14 09:29:25 +08:00
    boris1993
        1
    boris1993  
       Mar 13, 2019 via Android
    错误说 输入长度必须是 8 的整数倍

    以此为线索搜索一下?
    cnhongwei
        2
    cnhongwei  
       Mar 14, 2019
    3des 加密前不是密钥长度时,会做 padding。所以加密后数据一般比加密前数据长。所以你的错误有两种可能,1 种是加密算法有错误,取加密结果时,没有取到对应的字节数,另 1 种就是在 byte[]和 inputstream 转换过程中有 bug,造成数据不全。你在每个过程中打印一下数据长度就清楚了。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3779 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 04:35 · PVG 12:35 · LAX 21:35 · JFK 00:35
    ♥ Do have faith in what you're doing.