3

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

Community
  • 1
  • 1
eadam
  • 23,151
  • 18
  • 48
  • 71

1 Answers1

4

You should use the Microsoft.AspNet.Security.DataProtection package. The 2 main interfaces you can use are:

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 these available.

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

davidfowl
  • 37,120
  • 7
  • 93
  • 103
  • Your links are all broken... http://sourcebrowser.io/Browse/jchannon/katanaproject/src/Microsoft.Owin.Security/DataProtection/IDataProtector.cs http://sourcebrowser.io/Browse/jchannon/katanaproject/src/Microsoft.Owin.Security/DataProtection/IDataProtectionProvider.cs https://github.com/jchannon/katanaproject/blob/master/src/Microsoft.Owin.Security/DataProtection/IDataProtectionProvider.cs https://github.com/jchannon/katanaproject/blob/master/src/Microsoft.Owin.Security/DataProtection/IDataProtector.cs – Stefan Steiger Oct 01 '16 at 10:32