emrekizildas / EntityFrameworkCore.EncryptColumn

Encrypt & Decrypt your databases columns using EntityFramework Core.
MIT License
87 stars 40 forks source link

Decryption does not work #1

Closed svidem closed 3 years ago

svidem commented 3 years ago

I have tested you example https://github.com/emrekizildas/EntityFrameworkCore.EncryptColumn.Example and the first time it works, the second time I run it I get the following output:

ID: 9c2016b2-bf54-47d0-a9d0-23d94858ecad
Firstname: Emre
Lastname: Kizildas
Email Address: 
Identity Number: 
ID: d2a1252a-c7b3-41c6-b87a-e88ede34144a
Firstname: Emre
Lastname: Kizildas
Email Address: kizildas@icloud.com
Identity Number: 12345678901

It seems like it can't decrypt objects created by another instance of the DBContext.

svidem commented 3 years ago

Found the problem, add buffer when initializing the memory stream on row 52 in GenerateEncryptionProvider.

From using MemoryStream memoryStream = new(); To using MemoryStream memoryStream = new(buffer);

https://github.com/emrekizildas/EntityFrameworkCore.EncryptColumn/pull/2

emrekizildas commented 3 years ago

It's closed.

2