emrekizildas / EntityFrameworkCore.EncryptColumn

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

Specified key is not a valid size for this algorithm. #10

Closed Justicea83 closed 2 years ago

Justicea83 commented 2 years ago

Specified key is not a valid size for this algorithm.

emrekizildas commented 2 years ago

Can you explain your issue? Is it an error message or feature?

Justicea83 commented 2 years ago

i can't seem to get it right in terms of how the key should look like, so i get the error "the specified key is not a valid size for this algorithm" or "the key is not a valid base64 string"

and it an error am getting not a feature error

gala-s commented 2 years ago

@Justicea83 I ran into the key length issue as well, and it looks like the library just needs better documentation around key requirements. I was able to get past the issue by using a 256-bit key, I suspect the only accepted key sizes are 128, 192, and 256 bits.

RocketHatim commented 2 years ago

@gala-s Can you please give a specific example on how u got around this issue?

gala-s commented 2 years ago

@RocketHatim The string used for the key needs to be a specific size, I used 256 bits, but I suspect 128 & 192 will work as well. You can generate it using OpenSSL, or there are online generators like this one.

An example key I tested (obviously shouldn't be used for production since it's now posted publicly): r4u7x!A%C*F-JaNdRgUkXp2s5v8y/B?E

If you're using the NuGet package, I quickly ran into issue #12, and there isn't a functional package yet. The past two versions will encrypt the value, and you can retrieve it from the same instance of the DbContext, but it isn't actually written to the underlying DB, so when that context is disposed of the encrypted data is lost.