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 most common symmetric encryption algorithms are shown in the following diagram:

The most common asymmetric encryption algorithm is shown in the following diagram:

Note
Best Practice
Choose Advanced Encryption Standard (AES), which is based on the Rijndael algorithm for symmetric encryption. Choose RSA for asymmetric encryption. Do not confuse RSA with DSA. Digital Signature Algorithm (DSA) cannot encrypt data. It can only generate hashes and signatures.
Encrypting symmetrically with AES
To make it easier to reuse your protection code in the future, we will create a static class named Protector
in its own class library.
Symmetric...