“Padding is invalid and cannot be removed” using AesManaged

前端 未结 6 887
傲寒
傲寒 2020-11-29 04:55

I\'m trying to get simple encryption/decryption working with AesManaged, but I keep getting an exception when trying to close the decryption stream. The string here gets en

6条回答
  •  孤城傲影
    2020-11-29 05:32

    byte[] rawData = new byte[rawPlaintext.Length];

    You need to read the length of the buffer, that probably includes the necessary padding (IIRC, been a few years).

提交回复
热议问题