ASP.NET Core uses data protection providers to protect data that is exposed to third parties, such as cookies. The IDataProtectionProvider interface defines its contract and ASP.NET Core ships with a default instance registered in the DI framework of KeyRingBasedDataProtector, as illustrated in the following code snippet:
services.AddDataProtection();
The data protection provider is used by the cookies' authentication and also the cookie temp data provider APIs. A data protection provider exposes a method, CreateProtector, that is used to retrieve a protector instance, which can then be used to protect a string, as illustrated in the following code snippet:
var protector = provider.CreateProtector("MasteringAspNetCore");
var input = "Hello, World";
var output = protector.Protect(input); //CfDJ8AAAAAAAAAAAAAAAAAAAAA...uGoxWLjGKtm1SkNACQ
You can certainly use it for other purposes, but for the two presented...