Encrypt String in .NET Core

You really shouldn’t ever use Rijndael/RijndaelManaged in .NET. If you’re using it with a BlockSize value of 128 (which is the default) then you’re using AES, as I explained in a similar question.

The symmetric encryption options available in .NET Core are:

  • AES (System.Security.Cryptography.Aes.Create())
  • 3DES (System.Security.Cryptography.TripleDES.Create())

And for asymmetric encryption

  • RSA (System.Security.Cryptography.RSA.Create())

Especially on .NET Core the factories are the best way to go, because they will give back an object which works on the currently executing operating system. For example, RSACng is a public type but only works on Windows; and RSAOpenSsl is a public type but is only supported on Linux and macOS.

Leave a Comment