Encrypting and decrypting data
In .NET Core, there are multiple encryption algorithms you can choose from.
Some algorithms are implemented by the operating system and their names are suffixed with CryptoServiceProvider
. Some algorithms are implemented in .NET Core and their names are suffixed with Managed
.
Some algorithms use symmetric keys, and some use asymmetric keys. The main asymmetric encryption algorithm is RSA.
Symmetric encryption algorithms use CryptoStream
to encrypt or decrypt large amounts of bytes efficiently. Asymmetric algorithms can only handle small amounts of bytes, stored in a byte array instead of a stream.
The most common symmetric encryption algorithms derive from the abstract
class named SymmetricAlgorithm
and are shown in the following list:
- AES
- DESCryptoServiceProvider
- TripleDESCryptoServiceProvider
- RC2CryptoServiceProvider
- RijndaelManaged
If you need to write code to decrypt some data sent by an external system...