简体   繁体   中英

Non-ASP.Net equivalent of MachineKey.Protect/Unprotect

Is there a simple to use encrypt/decrypt method outside the System.Web.Security namespace that are as easy to use as MachineKey.Protect/MachineKey.Unprotect() ?

Or does anyone know if you can set up this outside ASP.Net as my quick trial showed that it seemed to generate a new key or something in between app restarts meaning you couldn't decrypt anything between restarts of the app.

I can roll my own using the appropriate classes, I was just wondering if they'd finally provided a simpler API?

I was searching for this as well. And after spent a few hours digging around, I found System.Security.Cryptography.ProtectedData . The usage is very similar, just that you need to provide the scope. And here's the best part: it's available from .NET 2.0.

Hope this helps someone someday.

The MachineKey in asp.net is autogenerated every time it starts up. To get around this you can set the MachineKey explicitly.

Of course, if the process is running on the same machine as your potential hacker, it's all a bit pointless.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM