We aspire to achieve encryption and decryption in a way that ensures the length of the encrypted result aligns with the length of the original data. How can this objective be accomplished in .NET code?
For example:
string chars = "abcdeABCDE12345"; int resLen = 6;
String to encrypt:: Hello Word!
Result: CE1b5h
It's possible with AES CFB mode.
Simple implementation:
Usage:
Note:
That solution encrypts and decrypts to bytes array, if your goal is to get a string you can convert it by
Encoding.UTF8.GetString(bytes)