Stopping decryption before EOF throws exception: Padding is invalid and cannot be removed

前端 未结 5 1764
刺人心
刺人心 2021-02-14 12:01

This is the scenario we have: We have huge encrypted files, in the order of gigabytes that we can decrypt correctly if we read them until the end. The problem arises when we ar

5条回答
  •  -上瘾入骨i
    2021-02-14 13:06

    As I understand it, the exception is thrown when the last byte read is not a valid padding byte. When you intentionally close the stream early, the last byte read will most likely be considered "invalid padding" and the exception is thrown. Since you're ending intentionally, you should be safe ignoring the exception.

提交回复
热议问题