Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MachineKey.Protect() equivalent in ASP.NET Core

What is the equivalent (if there is one) of MachineKey.Protect() and MachineKey.Unprotect() in ASP.NET Core

like image 817
webwake Avatar asked Jun 06 '17 18:06

webwake


People also ask

What is data protection in ASP.NET Core?

The ASP.NET Core data protection provides a cryptographic API to protect data, including key management and rotation. Web applications often need to store security-sensitive data. Windows provides a data protection API, DPAPI, but Windows DPAPI isn't intended for use in web applications.

How do I find the Machinekey for web config?

Open IIS manager. Double-click the Machine Key icon in ASP.NET settings in the middle pane: Now you can click Generate Keys on the right pane to generate random MachineKeys. When you click Apply, all settings will be saved in the web.

What is Machinekey?

Machine keys help protect Forms authentication cookie data and page-level view state data. They also verify out-of-process session state identification. ASP.NET uses the following types of machine keys: A validation key computes a Message Authentication Code (MAC) to confirm the integrity of the data.


2 Answers

the new dataprotection api is what you are looking for https://docs.microsoft.com/en-us/aspnet/core/security/data-protection/

like image 107
Joe Audette Avatar answered Oct 08 '22 10:10

Joe Audette


you can use this nuget package from below url https://www.nuget.org/packages/SFSecurity/1.0.0#

or directly install by command "Install-Package SFSecurity -Version 1.0.0"

like image 35
user2735422 Avatar answered Oct 08 '22 11:10

user2735422