79357026

Date: 2025-01-15 03:58:24
Score: 1.5
Natty:
Report link

You're using PaddingMode.None which requires the input data to be exactly divisible by the block size (16 bytes for AES).

Try encrypting/decrypting TESTTESTTESTTEST (4 TESTs, 16 bytes), and you will get the correct result like the first screenshot.

I prefer you use PKCS7 padding instead of None padding, as PKCS7 does not have this issue.

Change

aesAlg.Padding = PaddingMode.None;

To

aesAlg.Padding = PaddingMode.PKCS7;

None Padding

PKCS7 Padding

Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Macro Wong