AES encryption / decrption no longer works after upgrade to .net6.0

Tommy Lu 20 Reputation points
2023-06-15T14:46:59.8866667+00:00

hi, we are in progress of upgrade our c# base project from core 3.1 to 6.0, as part of the process of moving from win10 + vs2019 to win11 + vs2022.

After upgraded all necessary binaries and able to run a clean build on win11 + vs2022, however, we realized our unit tests that involving string encryption, then decrypt, no longer works.

From a very high level,
We use AES.Create() , and our test case, for example, encrypt a string, let's say "MyContent", and then tried to decrypt the result, would end up with "MyConte", with 2 characters short.

On the exact same code when running in my win10 + vs2019 with the same project that is still on core3.1, everything worked and passed.

One thing I noticed, but not sure if that contribute to the issue, is the object that returned from AES.Create() call, the KeyValue object returned in win11 + vsts2022 + .net6.0 is null, but return size of [32] in win10 + vs2019 + .net core 3.1.

wondering if this is a known issue with workaround that we could use? Any comment / feedback is greatly appreciated. Thanks.

Developer technologies | C#
{count} votes

Accepted answer
  1. Bruce (SqlWork.com) 78,161 Reputation points Volunteer Moderator
    2023-06-15T17:36:25.12+00:00
    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.