4 Replies - 4875 Views - Last Post: 04 May 2012 - 04:51 AMRate Topic:

AES decrypting problem(C#)

Posted 04 May 2012 - 01:46 AM

Hi guys!

I create project for a encrypt and decrypt files with AES method and i have a problem with exception "Padding is invalid and cannot be removed". If you have any idea for solution of my problem, please tell me.

Re: AES decrypting problem(C#)

Posted 04 May 2012 - 04:19 AM

The size of a block for AES is fixed, but you are telling it to read less than a block size (Line 36) so it's telling you that it needs the rest of the block (padding isn't valid). Why are you telling it the size at all? Try following the example on the documentation page, it's shorter than your code and it actually works.

Re: AES decrypting problem(C#)

Posted 04 May 2012 - 04:51 AM

I see this example on one website and I tested this code(because I had problems with implementation AES algorithm) and its work. Then I have programmed my version where I didn use the same parameters(in decrypt function), because I wanted to have only 2 parameters(text and key).