What encryption algorithm do we use in Asp.net 5 Core

Nowadays almost all encryption algorithms start giving me errors when switching project type from Asp.net 5.0 to Asp.net 5.0 Core. This is because they all require the System.Security.Cryptography namespance, which is not available in Core 5.0. See some code examples here . Any idea that we could use in Asp.net core 5.0?

+3


source to share


1 answer


You must use the Microsoft.AspNet.Security.DataProtection package. There are 2 main interfaces that you can use:

https://github.com/aspnet/DataProtection/blob/dev/src/Microsoft.AspNet.Security.DataProtection/IDataProtectionProvider.cs

and



https://github.com/aspnet/DataProtection/blob/dev/src/Microsoft.AspNet.Security.DataProtection/IDataProtector.cs

In your web application, within the ConfigureServices method, call AddDataProtection on the service collection to make them available.

From there, you should be able to access the IDataProtectionProvider via dependency injection.

+4


source







All Articles