I'm trying to encrypt a string with RijndaelManaged
in order to send it to a third-party service. I've implemented the procedure in older versions of .Net framework (4.5, 4.6.x) like below:
RijndaelManaged rm= new RijndaelManaged();
rm.KeySize = 256;
rm.BlockSize = 256;//causes exception in dotnet core 2.1
rm.Padding = PaddingMode.PKCS7;
rm.Key = Convert.FromBase64String(this.Key);
rm.IV = Convert.FromBase64String(this.IV);
var encrypt = rm.CreateEncryptor(rm.Key, rm.IV);
According to documentation, RijndaelManaged
class can be used with BlockSize = 256
. But, when the code is running in dotenet core 2.1, an exception thrown:
System.PlatformNotSupportedException: BlockSize must be 128 in this implementation. at System.Security.Cryptography.RijndaelManaged.set_BlockSize(Int32 value)
UPDATE
Thanks to @Access-Denied's response, according to this, I've noticed that it may be a mistake in dotnet core documentation and I can't use a 256 long BlockSize
with RijndaelManaged
class. As I mentioned, encrypted data is going to be sent to a third-party service. I have to use Rijndael with a 32 long IV
. How can I handle that?
IV
from the third-party with 32 lengths. – Dupuisaes
to hold it? If that isn't intentional obfuscation then you are confused. – Hales